Mantis - Squeak
Viewing Issue Advanced Details
2404 VM feature N/A 12-23-05 01:34 01-18-06 19:23
tim  
tim  
high  
closed 3.8  
fixed  
none    
none 3.8  
0002404: Add VM filename conversion access and endianness access to interpreterProxy for plugin use
Original request:-
    From: bert@impara.de
    Subject: Plugins and Platforms
    Date: November 25, 2005 3:47:42 AM PST (CA)
    To: vm-dev@discuss.squeakfoundation.org

Hi folks,

when writing a plugin in Slang I encountered two problems wrt platform specifics:

1) convert a squeak pathname to a platform pathname:

    * my plugin links to a library that expects a platform file path
    * must convert from Squeak path (char encoding etc.)
    * sqFilenameFromString() should do this

    * PROBLEM: this does not work in an external plugin
    * because it is just a macro pointing to some platform-code function that would have to be linked to the external plugin

    * PROPOSAL: provide an ioFilenameFromString() function exported from the VM
    * looked up by plugin via interpreterProxy->ioLoadFunctionFrom("ioFilenameFromString", "")
    * could trivially be implemented by using sqFilenameFromString macro?

2) endianness:

    * I need to know the current platform's endianness
    * because the linked library provides 8 bit bitmap data in platform order
    * and I want to adjust the Squeak form from the plugin (set depth to -8 on little-endian machine)

    * PROBLEM: which function/macro to use?

    * there seem to be several:
    - LSB_FIRST used in B3DAcceleratorPlugin.c
    - MSB_FIRST used in sqWin32Window.c
    - WORDS_BIGENDIAN defined on Mac OS and Unix - is this the one?
An interpreterProxy function for ioFilenameFromString is easy enough - we have sqFileNameFromString provided in the base code. It is nominally a macro although several platforms recast it as a function. There is also the slight fiddly bit of the sqFilenameFromStringOpen stuff for OSX to consider.
It looks as if simply making an Interpreter method ioFilenameFromString that points to sqfilenameFromString will do. Add equivalent to InterpreterProxy as well and of course to sqVirtualMachine.[ch]

There isn't any single universal macro or value to indicate endianess so I'll add one. A macro will be most useful since it can be set in a sqPlatformSpecific.h or from a makefile command as a result of autoconf or other OS gymnastics.
 Interpreter-isBigEnder-dtl.1.cs.gz [^] (639 bytes) 12-29-05 03:29
 EndianPlugin-dtl.1.cs.gz [^] (737 bytes) 12-29-05 03:29

Notes
(0003396)
lewis   
12-29-05 03:30   
In VMMaker3.8b5-64, a macro is introduced for VMENDIANNESS. This should not be necessary, since endianness can be tested at runtime.

Interpreter-isBigEnder-dtl.1.cs provides the runtime check.

EndianPlugin-dtl.1.cs is a plugin to verify that it works.

This has been tested only on an Intel 32 bit box, so it needs at least a check on a Mac. To test, build the EndianPlugin, then evaluate "EndianPlugin endianness = Smalltalk endianness", which should evaluate to true.
(0003420)
tim   
01-02-06 21:04   
VMMaker3.8b5-64B has fixes.
(0003536)
MarcusDenker   
01-18-06 19:23   
fixed in vmmaker