[Vm-dev] Cross file updates
tim Rowledge
tim at rowledge.org
Fri Mar 8 02:07:45 UTC 2013
On 07-03-2013, at 5:13 PM, "David T. Lewis" <lewis at mail.msen.com> wrote:
>
> Uh-oh. I don't like what I'm seeing here. I think there is a bug in the
> code generator for SmartSyntaxInterpreterPlugin.
>
> HostWindowPlugin deals with Bitmaps, which are arrays of 32-bit words.
>
> The #primitiveShowHostWindow:bits:width:height:depth:left:right:top:bottom:
> method declares the parameter as
>
> self var: #dispBits type: 'unsigned char * '.
>
> But the translated code in primitiveShowHostWindowRect() renders it incorrectly as
>
> usqInt *dispBits;
>
> and later in the same method casts it to 'unsigned *' here:
>
> dispBits = ((unsigned *) (interpreterProxy->firstIndexableField(interpreterProxy->stackValue(7))));
The self var: #dispBits type: 'unsigned char * '. line seems to do nothing in the current VMMaker; I'm pretty sure it used to. Somewhere the SmartSyntax codegen stuff is over-riding that decl (or ignoring is more likely I guess) because of the primitive declaration using a 'WordArray'; that causes the use of (unsigned *). Using ByteArray makes is use (char *) instead.
>
> Meanwhile the header file in Cross declares it correctly for ioShowDisplayOnWindow
> as 'unsigned * '.
I returned that to 'unsigned char *', though that doesn't strictly agree with the plugin 'char *'.
>
> Either 'unsigned char *' or 'unsigned *' would be reasonable declarations,
> but 'usqInt *' is definitely wrong because usqInt may be 64 bits in a 64-bit
> object memory, and Bitmaps are always 32 bit in either the 32-bit or the
> 64-bit object memory.
>
> So the declarations in Cross and in VMMaker are inconsistent, *and* the
> code generated by VMMaker is wrong. I think it's a bug that is specific to
> SmartSyntaxInterpreterPlugin code generation, though I'm not certain.
I'm reasonably sure that the VMMaker revision I just committed gets us closer. There is still a clash between unsigned char * and char * but for now I can survive it with an ugly compiler flag.
>
> Ugh.
>
> Dave
>
> p.s. I think that 'unsigned *' is a better declaration than 'unsigned char *'
> because without it the platform code would need to sort out the little/big
> endianness in the 32 bit words, right? Or did I get that bass ackwards …
It doesn't matter a lot in this case because we don't use the pointer for anything more than pointing; no structure maths for us!
tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
"Bother" said Pooh, as he flunked the the sobriety test.
More information about the Vm-dev
mailing list