[Vm-dev] Cross file updates

David T. Lewis lewis at mail.msen.com
Fri Mar 8 01:13:41 UTC 2013


On Thu, Mar 07, 2013 at 02:26:48PM -0800, tim Rowledge wrote:
> 
> 
> On 06-03-2013, at 10:59 PM, Ian Piumarta <piumarta at speakeasy.net> wrote:
> > 
> >> 4.4-ish HostWindowPlugin.h had 'unsigned char *' until I changed it. Unix uses 'unsigned char *', windows now uses 'unsigned char *', Mac now uses 'unsigned char *' and RISC OS still uses 'unsigned *'.
> > 
> > Then everything was in agreement except ROS, which was using 'unsigned int *' and should be changed to conform.
> 
> 
> I'm entirely content to make the RISC OS code conform to everyone else's usage - but it does require a minor change to the plugin code; the 'dispBits' var in primitiveShowHostWindowRect is specified as WordArray which generates as (unsigned *)(foo). Clearly it is an error to pass an unsigned * to a function specified to take an unsigned char *. 
> 
> Changing to ByteArray generates dispBits as (char *) - and here I'll note the 
> 	self var: #dispBits type: 'unsigned char * '.
> in the method as having no effect whatsoever - which is better but still strictly an error vs unsigned char *. 
> At least, that is the viewpoint encoded into NorCroft C and I'm not about to debate C syntax with Prof. Alan Mycroft. Anyone that wishes to do so can find contact information at http://www.codemist.co.uk/ncc/index.html
> 
> I *can* suppress all implicit cast errors and make it compile but really I don't like that much. Errors are reported for a reason. 
>

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))));

Meanwhile the header file in Cross declares it correctly for ioShowDisplayOnWindow
as 'unsigned * '.

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.

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 ...
 


More information about the Vm-dev mailing list