<br><br><div class="gmail_quote">On Sat, May 21, 2011 at 7:44 AM, David T. Lewis <span dir="ltr"><<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>></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>
><br>
> On 17.05.2011 20:27, Eliot Miranda wrote:<br>
> ><br>
> >I'm just trying to eliminate the explicit references to CrLfFileStream<br>
> >in the Cog VMMaker, but I've hit a snag.<br>
<br>
<br>
Hi Eliot,<br>
<br>
I don't know if you have done anything further on this, </blockquote><div><br></div><div>yes, I added a single method cuxz there'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 <lf> 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'll add the same to<br>
VMMaker classic.<br>
<br>
HTH,<br>
Dave<br>
<br>
> >e.g. there's this idiom:<br>
> ><br>
> >InterpreterPlugin class methods for translation<br>
> >storeString: s onFileNamed: fileName<br>
> >"Store the given string in a file of the given name."<br>
> ><br>
> >| f |<br>
> >f := CrLfFileStream forceNewFileNamed: fileName.<br>
> >f nextPutAll: s.<br>
> >f close.<br>
> ><br>
> >that I'd like to replace with<br>
> ><br>
> >VMMaker class methods for utilities<br>
> >newFileStream<br>
> >"Always output files in unix lf format.<br>
> >A single format is friendlier to e.g. external version control systems.<br>
> >The Microsoft and old MacOS classic C compilers all accept lf format<br>
> >files."<br>
> ><br>
> >^MultiByteFileStream new<br>
> >lineEndConvention: #lf;<br>
> >yourself<br>
> ><br>
> >InterpreterPlugin class methods for translation<br>
> >storeString: s onFileNamed: fileName<br>
> >"Store the given string in a file of the given name."<br>
> ><br>
> >| f |<br>
> >f := VMMaker newFileStream forceNewFileNamed: fileName.<br>
> >f nextPutAll: s.<br>
> >f close.<br>
> ><br>
> >but only class-side methods understand forceNewFileNamed:, and hence<br>
> >one would have to write<br>
> ><br>
> ><br>
> ><br>
> >InterpreterPlugin class methods for translation<br>
> >storeString: s onFileNamed: fileName<br>
> >"Store the given string in a file of the given name."<br>
> ><br>
> >| f |<br>
> >f := MultiByteFileStream forceNewFileNamed: fileName.<br>
> >f lineEndConvention: #lf.<br>
> >f nextPutAll: s.<br>
> >f close<br>
> ><br>
> >which is a tad tedious and distributed. I could have a set of<br>
> >convenience methods in VMMaker class, forceNewFileStream:<br>
> >oldFileStream etc. There could be subclasses of MultiByteFileStream<br>
> >purely for instance creation (MultiByteLfFileStream et al). Or...?<br>
> > Any thoughts?<br>
> ><br>
> >best,<br>
> >Eliot<br>
> ><br>
> ><br>
> ><br>
> I'd suggest wrappingthe *fileNamed:do: protocol in a new class, state in<br>
> the class comment that it's only purpose is to ensure all VM files are<br>
> written with consistent line endings, and use that class' methods<br>
> exclusively elsewhere.<br>
> Doesn't even need to be a subclass really:<br>
><br>
> VMFileStream class >> forceNewNamed: fileName do: aBlock<br>
> ^FileStream forceNewFileNamed: fileName do: [:fs |<br>
> fs lineEndConvention: #lf.<br>
> aBlock value: fs]<br>
><br>
> Basically, reintroduce a variant of CRLFFileStream for use specifically<br>
> in the VM :)<br>
><br>
> Cheers,<br>
> Henry<br>
<br>
<br></blockquote></div><br>