<br><br><div class="gmail_quote">On Sat, May 21, 2011 at 7:44 AM, David T. Lewis <span dir="ltr">&lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
 <br>On Wed, May 18, 2011 at 10:40:25AM +0200, Henrik Sperre Johansen wrote:<br>
&gt;<br>
&gt; On 17.05.2011 20:27, Eliot Miranda wrote:<br>
&gt; &gt;<br>
&gt; &gt;I&#39;m just trying to eliminate the explicit references to CrLfFileStream<br>
&gt; &gt;in the Cog VMMaker, but I&#39;ve hit a snag.<br>
<br>
<br>
Hi Eliot,<br>
<br>
I don&#39;t know if you have done anything further on this, </blockquote><div><br></div><div>yes, I added a single method cuxz there&#39;s really only the one case, forceNewFileNamed:.  So just one more thing to merge when we get to it :)</div>
<div><br></div><div>but thanks!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">but the attached<br>
is a trivial replacement for CrLfFileStream that can be used in VMMaker<br>
to get rid of the CrLfFileStream dependency and produce &lt;lf&gt; line<br>
terminators in the generated sources.<br>
<br>
I tried this in VMMaker, changing the references from CrLfFileStream<br>
to CCodeFileStream, and it seems fine for all the source code generation.<br>
<br>
Let me know what approach you are taking and I&#39;ll add the same to<br>
VMMaker classic.<br>
<br>
HTH,<br>
Dave<br>
<br>
&gt; &gt;e.g. there&#39;s this idiom:<br>
&gt; &gt;<br>
&gt; &gt;InterpreterPlugin class methods for translation<br>
&gt; &gt;storeString: s onFileNamed: fileName<br>
&gt; &gt;&quot;Store the given string in a file of the given name.&quot;<br>
&gt; &gt;<br>
&gt; &gt;| f |<br>
&gt; &gt;f := CrLfFileStream forceNewFileNamed: fileName.<br>
&gt; &gt;f nextPutAll: s.<br>
&gt; &gt;f close.<br>
&gt; &gt;<br>
&gt; &gt;that I&#39;d like to replace with<br>
&gt; &gt;<br>
&gt; &gt;VMMaker class methods for utilities<br>
&gt; &gt;newFileStream<br>
&gt; &gt;&quot;Always output files in unix lf format.<br>
&gt; &gt;A single format is friendlier to e.g. external version control systems.<br>
&gt; &gt;The Microsoft and old MacOS classic C compilers all accept lf format<br>
&gt; &gt;files.&quot;<br>
&gt; &gt;<br>
&gt; &gt;^MultiByteFileStream new<br>
&gt; &gt;lineEndConvention: #lf;<br>
&gt; &gt;yourself<br>
&gt; &gt;<br>
&gt; &gt;InterpreterPlugin class methods for translation<br>
&gt; &gt;storeString: s onFileNamed: fileName<br>
&gt; &gt;&quot;Store the given string in a file of the given name.&quot;<br>
&gt; &gt;<br>
&gt; &gt;| f |<br>
&gt; &gt;f := VMMaker newFileStream forceNewFileNamed: fileName.<br>
&gt; &gt;f nextPutAll: s.<br>
&gt; &gt;f close.<br>
&gt; &gt;<br>
&gt; &gt;but only class-side methods understand forceNewFileNamed:, and hence<br>
&gt; &gt;one would have to write<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;InterpreterPlugin class methods for translation<br>
&gt; &gt;storeString: s onFileNamed: fileName<br>
&gt; &gt;&quot;Store the given string in a file of the given name.&quot;<br>
&gt; &gt;<br>
&gt; &gt;| f |<br>
&gt; &gt;f := MultiByteFileStream forceNewFileNamed: fileName.<br>
&gt; &gt;f lineEndConvention: #lf.<br>
&gt; &gt;f nextPutAll: s.<br>
&gt; &gt;f close<br>
&gt; &gt;<br>
&gt; &gt;which is a tad tedious and distributed.  I could have a set of<br>
&gt; &gt;convenience methods in VMMaker class, forceNewFileStream:<br>
&gt; &gt;oldFileStream etc.  There could be subclasses of MultiByteFileStream<br>
&gt; &gt;purely for instance creation (MultiByteLfFileStream et al).  Or...?<br>
&gt; &gt; Any thoughts?<br>
&gt; &gt;<br>
&gt; &gt;best,<br>
&gt; &gt;Eliot<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; I&#39;d suggest wrappingthe *fileNamed:do: protocol in a new class, state in<br>
&gt; the class comment that it&#39;s only purpose is to ensure all VM files are<br>
&gt; written with consistent line endings, and use that class&#39; methods<br>
&gt; exclusively elsewhere.<br>
&gt; Doesn&#39;t even need to be a subclass really:<br>
&gt;<br>
&gt; VMFileStream class &gt;&gt; forceNewNamed: fileName do: aBlock<br>
&gt;     ^FileStream forceNewFileNamed: fileName do: [:fs |<br>
&gt;             fs lineEndConvention: #lf.<br>
&gt;             aBlock value: fs]<br>
&gt;<br>
&gt; Basically, reintroduce a variant of CRLFFileStream for use specifically<br>
&gt; in the VM :)<br>
&gt;<br>
&gt; Cheers,<br>
&gt; Henry<br>
<br>
<br></blockquote></div><br>