<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: Making a pluggable primitive - basic questions</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Tim</FONT>
<BR><FONT SIZE=2>Thanks for the pointers. There seems to be a problem with the swiki but I will take a look when it's up. A few comments in-line.</FONT></P>
<P><FONT SIZE=2>Bob</FONT>
</P>
<P><FONT SIZE=2>> Hi</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> I'm trying to build a plug-in and getting pretty lost at the moment.</FONT>
<BR><FONT SIZE=2>Sounds like you haven't been pointed to the swiki pages yet: - Start </FONT>
<BR><FONT SIZE=2>at <A HREF="http://minnow.cc.gatech.edu/squeak/2105" TARGET="_blank">http://minnow.cc.gatech.edu/squeak/2105</A> and particularly follow </FONT>
<BR><FONT SIZE=2>links to NamedPrimitives and similar.</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> 1. Create the smalltalk class to call the primitive. Something like</FONT>
<BR><FONT SIZE=2>> this:</FONT>
<BR><FONT SIZE=2>> run</FONT>
<BR><FONT SIZE=2>> <primitive: 'primitiveRun' module:'PhasingDSPPlugin'></FONT>
<BR><FONT SIZE=2>> ^ false</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>That's a reasonable start. You might want to return 'self </FONT>
<BR><FONT SIZE=2>primitiveFailed' instead of false or you might have some way to check </FONT>
<BR><FONT SIZE=2>the various parameters and settings relevant to the prim and retry. </FONT>
<BR><FONT SIZE=2>You might look at some of the primitive calling methods in BitBlt to </FONT>
<BR><FONT SIZE=2>see examples.</FONT>
</P>
<BR>
<P><FONT SIZE=2>> 2. Create the primitive code calling code in Slang dialect. Something</FONT>
<BR><FONT SIZE=2>> like this (I'm sure this is very incomplete/plain wrong):</FONT>
<BR><FONT SIZE=2>> primitiveRun</FONT>
<BR><FONT SIZE=2>> SmartSyntaxInterpreterPlugin doPrimitive: #StartStream</FONT>
<BR><FONT SIZE=2>> withArguments: #().</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> Should I be using interpreterProxy here. Where does the</FONT>
<BR><FONT SIZE=2>> interpreterProxy instance get created.</FONT>
<BR><FONT SIZE=2>>> Here you've clearly been handed the wrong end of an inappropriate </FONT>
<BR><FONT SIZE=2>>> stick. No need for anything like this and you don't have to worry </FONT>
<BR><FONT SIZE=2>>> about any interpreterProxy.</FONT>
<BR><FONT SIZE=2>>> Your method in 1. will do all that is needed to actually call the </FONT>
<BR><FONT SIZE=2>>> prim when it exists. The #doPrimitive:withArguments: stuff is to do </FONT>
<BR><FONT SIZE=2>>> with simulating the plugin code and I think it is not fully </FONT>
<BR><FONT SIZE=2>>> functional right now anyway.</FONT>
</P>
<P><FONT SIZE=2>I was looking at various code snippets, shows how you can be misled. </FONT>
</P>
<P><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> 3. Run Slang to convert (2) to 'C'.</FONT>
<BR><FONT SIZE=2>>> Not quite. You need to create a plugin class as a subclass of </FONT>
<BR><FONT SIZE=2>>> SmartSyntaxInterpreterPlugin (bad name I know but better than </FONT>
<BR><FONT SIZE=2>>> 'TestInterpreterPlugin' at least) and implement your function.</FONT>
<BR><FONT SIZE=2>>> By default the plugin will be named the same as your class but you </FONT>
<BR><FONT SIZE=2>>> can override that (see implementors of #moduleName I think) if you </FONT>
<BR><FONT SIZE=2>>> like. Remember that the actual generated plugin name needs to match </FONT>
<BR><FONT SIZE=2>>> what you put in the method in 1. above! Don't Ask Me How I Know.</FONT>
</P>
<P><FONT SIZE=2>Ok, I've done that. I'm not sure what 'implement your function' means. I already have my function, it's in 'C' and I want to bridge to it. I guess the code here makes that bridge but not sure what I need to write. Guess that's on the Swiki somewhere.</FONT></P>
<P><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>> I know I need to use VMMaker and</FONT>
<BR><FONT SIZE=2>> should only need to convert this one method.</FONT>
<BR><FONT SIZE=2>>> Well, one plugin rather than one method.</FONT>
</P>
<BR>
<P><FONT SIZE=2>> I have looked at</FONT>
<BR><FONT SIZE=2>> VMMakerTool but don't know if this is the right thing to use. If it is</FONT>
<BR><FONT SIZE=2>> it's not clear to me how one gets a new plugin into the 'plugins not</FONT>
<BR><FONT SIZE=2>> built' list and the ones listed are not draggable anyway. Does my code</FONT>
<BR><FONT SIZE=2>> need to go into VMMaker-Plugins or is this just a convention? Also </FONT>
<BR><FONT SIZE=2>> tried</FONT>
<BR><FONT SIZE=2>> cCodeGenerator cCodeForMethod but couldn't get it to work.</FONT>
<BR><FONT SIZE=2>>> Sounds to me like you really need to read the swiki page(s) mentioned </FONT>
<BR><FONT SIZE=2>>> above. Try that and 'call us back'.</FONT>
</P>
<P><FONT SIZE=2>Will do.</FONT>
</P>
<P><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> 4 Assuming someone can put me right on (3) I then have to compile and</FONT>
<BR><FONT SIZE=2>> link (on XP by the way) for which I can use VisualStudio or Borland.</FONT>
<BR><FONT SIZE=2>> What do I compile/link against? I don't see any header files or </FONT>
<BR><FONT SIZE=2>> libs in</FONT>
<BR><FONT SIZE=2>> the squeak distribution.</FONT>
<BR><FONT SIZE=2>>> The win32 VM is built with gcc and some tools Andreas has packaged up </FONT>
<BR><FONT SIZE=2>>> somewhere. I'm not sure where but somebody will know. The swiki page </FONT>
<BR><FONT SIZE=2>>> on building a windows vm seems to point to a dead server right now.</FONT>
<BR><FONT SIZE=2>></FONT>
<BR><FONT SIZE=2>> 5. Having got my compiled/linked code, not sure what form that should</FONT>
<BR><FONT SIZE=2>> take, is it object format, linked to a .lib or .dll. How do I register</FONT>
<BR><FONT SIZE=2>> it with Squeak so it knows how to play.</FONT>
<BR><FONT SIZE=2>>> Once it is built it can go in a variety of places, somewhat dependent </FONT>
<BR><FONT SIZE=2>>> on the platform. Pretty much all of them are ok with the plugin (it's </FONT>
<BR><FONT SIZE=2>>> a .dll on window) in the same directory as the vm for testing </FONT>
<BR><FONT SIZE=2>>> purposes. When you run you method to call the prim it will lookup the </FONT>
<BR><FONT SIZE=2>>> plugin and load it and cache the function pointer(s) and run it. Next </FONT>
<BR><FONT SIZE=2>>> time you run it the pointer can be used directly of course.</FONT>
<BR><FONT SIZE=2>></FONT>
</P>
<BR>
<P><FONT SIZE=2>tim</FONT>
<BR><FONT SIZE=2>--</FONT>
<BR><FONT SIZE=2>tim Rowledge; tim@rowledge.org; <A HREF="http://www.rowledge.org/tim" TARGET="_blank">http://www.rowledge.org/tim</A></FONT>
<BR><FONT SIZE=2>BASIC is to computer programming as QWERTY is to typing.</FONT>
</P>
<BR>
<BR>
<P><STRONG>*** Confidentiality Notice ***</STRONG>
Proprietary/Confidential<BR>Information belonging to CGI Group Inc. and its
affiliates<BR>may be contained in this message. If you are not a
recipient<BR>indicated or intended in this message (or responsible
for<BR>delivery of this message to such person), or you think for<BR>any reason
that this message may have been addressed to you<BR>in error, you may not use or
copy or deliver this message<BR>to anyone else. In such case, you should
destroy this<BR>message and are asked to notify the sender by reply
email.</P>
</BODY>
</HTML>