[Vm-dev] Is B2DPlugin C code only?

gettimothy gettimothy at zoho.com
Sun May 18 12:39:03 UTC 2014


Hi David,



I was going to comment on this last night, but I was falling asleep; you replied after I went to bed.




This one is a bit tricky. You are looking at B2DPlugin.c, which is the 
translated C code for one of the plugins that is written in Smalltalk. 
As you have noticed, it is not entirely obvious how this came to be, but 
if you look in the comment at the top fo the B2DPlugin.c file, you will 
see that it was automatically generated from class BalloonEnginePlugin. 
 
The tricky bit is that the name of the C source module is controlled by 
the #moduleName method in the Smalltalk class being generated. By default, 
the C module name is just the name of the class being translated. But if 
a class method #moduleName is provided, then this will specify the name of 
the generated C code. 
 
If you look at BalloonEnginePlugin, which is the class that is translated 
into B2DPlugin.c in C, you will see that it has a superclass BalloonEngineBase, 
and that the superclass does this: 
 
 BalloonEngineBase class>>moduleName 
 ^'B2DPlugin' 
 
So this is the method that causes the generated C file to be called B2DPlugin.c. 
 
The Smalltalk class comments give an indication of why B2DPlugin is organized 
in this manner. After reading the comments, you can see how the methods 
#shouldBeTranslated and #moduleName are implemented in BalloonEngineBase 
to control the code generation to C. 
 
You will notice also that there is a class BalloonEngineSimulation that is 
subclassed from BalloonEngineSimulation. This subclass is not translated to 
C, but instead provides support for running B2DPlugin directly in Smalltalk. 
 
This particular plugin is interesting because it represents a substantial 
amount of low level graphics code written directly in Smalltalk, not in C. 
The author was able to write in Smalltalk for clarity and ease of debugging, 
with no sacrifice of performance once the code was translated to compiled C. 
 
Dave
 
 




It took me all-freaking-day,(I went so far as to introduce a NotReallyAPlugin class that would spit out the "B2DPlugin" string I needed) but I learned exactly what you have posted.


Below are the plugins (Class <-- --> Class moduleName [which is the directory the c-code and build files go into])  that ship when you run the buildsqueak45image.sh script in Cog/images.




There are some interesting things in there.


AioPlugin <- -> AioPlugin

B3DAcceleratorPlugin <- -> B3DAcceleratorPlugin
BalloonEngineBase <- -> B2DPlugin
BitBltSimulation <- -> BitBltPlugin
DSAPlugin <- -> DSAPrims
ExternalLibrary <- -> nil
FFIPlugin <- -> SqueakFFIPrims
IA32ABIPlugin <- -> IA32ABI
InflatePlugin <- -> ZipPlugin
InterpreterPlugin <- -> InterpreterPlugin
KlattSynthesizerPlugin <- -> Klatt
LargeIntegersPlugin <- -> LargeIntegers
NewsqueakIA32ABIPlugin <- -> IA32ABI
RePlugin <- -> RePlugin
SoundCodecPlugin <- -> SoundCodecPrims
SqueakSSLPlugin <- -> SqueakSSL
ThreadedARMFFIPlugin <- -> ARM32FFIPlugin
ThreadedFFIPlugin <- -> SqueakFFIPrims
ThreadedIA32FFIPlugin <- -> IA32FFIPlugin
ThreadedPPCBEFFIPlugin <- -> PPC32FFIPlugin
UnixOSProcessPlugin <- -> UnixOSProcessPlugin
Win32OSProcessPlugin <- -> Win32OSProcessPlugin
XDisplayControlPlugin <- -> XDisplayControlPlugin

 



Of course(!) somebody on the pharo team had already figured this out had helpfully placed reminders like 




      IA32ABIPlugin "IA32ABI"
 In the defaultInternnalPlugins method. Being a dim-wit, I assumed that they where separate plugins--perhaps updated version/renaming.

Its funny how something so trivial can eat up hours.



Thanks for your reply.


tty




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20140518/74b60fc1/attachment.htm


More information about the Vm-dev mailing list