<!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>&gt; Hi</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt; 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&nbsp; </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&nbsp; </FONT>
<BR><FONT SIZE=2>links to NamedPrimitives and similar.</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt; 1. Create the smalltalk class to call the primitive. Something like</FONT>
<BR><FONT SIZE=2>&gt; this:</FONT>
<BR><FONT SIZE=2>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; run</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;primitive: 'primitiveRun' module:'PhasingDSPPlugin'&gt;</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^ false</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>That's a reasonable start. You might want to return 'self&nbsp; </FONT>
<BR><FONT SIZE=2>primitiveFailed' instead of false or you might have some way to check&nbsp; </FONT>
<BR><FONT SIZE=2>the various parameters and settings relevant to the prim and retry.&nbsp; </FONT>
<BR><FONT SIZE=2>You might look at some of the primitive calling methods in BitBlt to&nbsp; </FONT>
<BR><FONT SIZE=2>see examples.</FONT>
</P>
<BR>

<P><FONT SIZE=2>&gt; 2. Create the primitive code calling code in Slang dialect. Something</FONT>
<BR><FONT SIZE=2>&gt; like this (I'm sure this is very incomplete/plain wrong):</FONT>
<BR><FONT SIZE=2>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; primitiveRun</FONT>
<BR><FONT SIZE=2>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SmartSyntaxInterpreterPlugin doPrimitive: #StartStream</FONT>
<BR><FONT SIZE=2>&gt; withArguments: #().</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Should I be using interpreterProxy here. Where does the</FONT>
<BR><FONT SIZE=2>&gt; interpreterProxy instance get created.</FONT>
<BR><FONT SIZE=2>&gt;&gt; Here you've clearly been handed the wrong end of an inappropriate&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; stick. No need for anything like this and you don't have to worry&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; about any interpreterProxy.</FONT>
<BR><FONT SIZE=2>&gt;&gt; Your method in 1. will do all that is needed to actually call the&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; prim when it exists. The #doPrimitive:withArguments: stuff is to do&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; with simulating the plugin code and I think it is not fully&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; 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>&gt;</FONT>
<BR><FONT SIZE=2>&gt; 3. Run Slang to convert (2) to 'C'.</FONT>
<BR><FONT SIZE=2>&gt;&gt; Not quite. You need to create a plugin class as a subclass of&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; SmartSyntaxInterpreterPlugin (bad name I know but better than&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; 'TestInterpreterPlugin' at least) and implement your function.</FONT>
<BR><FONT SIZE=2>&gt;&gt; By default the plugin will be named the same as your class but you&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; can override that (see implementors of #moduleName I think) if you&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; like. Remember that the actual generated plugin name needs to match&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; 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>&nbsp;</FONT>
<BR><FONT SIZE=2>&gt; I know I need to use VMMaker and</FONT>
<BR><FONT SIZE=2>&gt; should only need to convert this one method.</FONT>
<BR><FONT SIZE=2>&gt;&gt; Well, one plugin rather than one method.</FONT>
</P>
<BR>

<P><FONT SIZE=2>&gt; I have looked at</FONT>
<BR><FONT SIZE=2>&gt; VMMakerTool but don't know if this is the right thing to use. If it is</FONT>
<BR><FONT SIZE=2>&gt; it's not clear to me how one gets a new plugin into the 'plugins not</FONT>
<BR><FONT SIZE=2>&gt; built' list and the ones listed are not draggable anyway. Does my code</FONT>
<BR><FONT SIZE=2>&gt; need to go into VMMaker-Plugins or is this just a convention? Also&nbsp; </FONT>
<BR><FONT SIZE=2>&gt; tried</FONT>
<BR><FONT SIZE=2>&gt; cCodeGenerator cCodeForMethod but couldn't get it to work.</FONT>
<BR><FONT SIZE=2>&gt;&gt; Sounds to me like you really need to read the swiki page(s) mentioned&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; above. Try that and 'call us back'.</FONT>
</P>

<P><FONT SIZE=2>Will do.</FONT>
</P>

<P><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt; 4 Assuming someone can put me right on (3) I then have to compile and</FONT>
<BR><FONT SIZE=2>&gt; link (on XP by the way) for which I can use VisualStudio or Borland.</FONT>
<BR><FONT SIZE=2>&gt; What do I compile/link against? I don't see any header files or&nbsp; </FONT>
<BR><FONT SIZE=2>&gt; libs in</FONT>
<BR><FONT SIZE=2>&gt; the squeak distribution.</FONT>
<BR><FONT SIZE=2>&gt;&gt; The win32 VM is built with gcc and some tools Andreas has packaged up&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; somewhere. I'm not sure where but somebody will know. The swiki page&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; on building a windows vm seems to point to a dead server right now.</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt; 5. Having got my compiled/linked code, not sure what form that should</FONT>
<BR><FONT SIZE=2>&gt; take, is it object format, linked to a .lib or .dll. How do I register</FONT>
<BR><FONT SIZE=2>&gt; it with Squeak so it knows how to play.</FONT>
<BR><FONT SIZE=2>&gt;&gt; Once it is built it can go in a variety of places, somewhat dependent&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; on the platform. Pretty much all of them are ok with the plugin (it's&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; a .dll on window) in the same directory as the vm for testing&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; purposes. When you run you method to call the prim it will lookup the&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; plugin and load it and cache the function pointer(s) and run it. Next&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&gt; time you run it&nbsp; the pointer can be used directly of course.</FONT>
<BR><FONT SIZE=2>&gt;</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.&nbsp; In such case, you should 
destroy this<BR>message and are asked to notify the sender by reply 
email.</P>
</BODY>
</HTML>