Squeak V3 (was: Final call for 2.9 updates)

John M McIntosh johnmci at smalltalkconsulting.com
Tue Feb 6 04:54:09 UTC 2001


>Quibbles found whilst trying to put together a new VM:-
>
>int dir_GetMacFileTypeAndCreator(char *filename, int filenameSize, 
>char *fType, char *fCreator)
>- what parameter limitations are intended here? Yes, I know I could
>probably make it null, but Acorn _does_ do file types and if there is a
>modest set I can translate them.

Ah on the mac the filename is upto 255 characters, the fType and 
fCreator are four byte ByteArrays. Could be bigger I guess, but the 
mac only returns four bytes. If you look at how the implementors of 
mimeTypesFor: fileName act you'll see you could add the acorn 
support...

I see in FilePlugin->primitiveDirectoryGetMacTypeAndCreator I 
constrained the size to 4, but we could change this..

macintosh users should look at
MacFileDirectory initializeTypeToMimeMappings
and consider submitting changesets if they want their most 
interesting file type to work

Also see
Morph/PasteUpMorph dropFiles: anEvent to see what should be done. 
Although shouldn't this really have some sort of resolver class to do 
the work about deciding what to do with the mimi type, perhaps a 
class ResolveMimeType, and you could do a perform: mimeType and have 
a doesNotUnderStand to handle the generic/unknown case, with methods 
for each of the known mime's This would make adding mimetype resolves 
easier than messing with dropFiles: each time you want add a new 
resolver, and of course subclassing the default resolver could make 
things easier to customize. (Anyone want to do thi?)

Also see the mac's FileTypesAndCreators.h if handy

>
>EXPORT(int) primitiveDisablePowerManager(void) {
>  & int ioDisablePowerManager(int disableIfNonZero);
>- this should be in a trivial plugin. It doesn't deserve to be in the
>kernel.

Likely but one of the issues is that you need to tap the logic every 
N seconds otherwise powermanagement reverts back to  normal on the 
mac. This is to prevent something from turning it off, then 
forgetting to turn it back on. However I guess I could have placed 
the logic in the InputSensor somewhere and remove the logic from the 
macintosh event loop.


>
>dropBlah
>- anybody care to expand on the rather thin comments in DropPlugin.c ?

Ah, the mac or the windows one?

int dropInit(void)
This doesn't get call anywhere in smalltalk, I and Windows does it at 
startup time so we can attach OS drag logic to the OS window.

int dropShutdown()
On the mac I remove the drag/drop logic from the window when Squeak 
terminates (nicely/crashes etc)

char *dropRequestFileName(int dropIndex)

returns an address to the dropIndex element of the list of files that 
have been dropped
1 to N of course. This is a C string.

int dropRequestFileHandle(int dropIndex) {

     //Code suggested to me was

     int fileHandle;
     int   size,classPointer;
     char *dropName = dropRequestFileName(dropIndex);
    
     if(!dropName)
         return interpreterProxy->nilObject();

     size = fileRecordSize();
     classPointer = interpreterProxy->classByteArray();
     fileHandle = 
interpreterProxy->instantiateClassindexableSize(classPointer, size);
     sqFileOpen(fileValueOf(fileHandle),(int)dropName, strlen(dropName), 0);
    
   return fileHandle;
}


for

int recordDragDropEvent(foo *theEvent, int theButtonState, int 
numberOfItems, int dragType) {
	sqDragDropFilesEvent *evt;

	evt = (sqDragDropFilesEvent*) nextEventPut();

	/* first the basics */
	evt->type = EventTypeDragDropFiles;
	evt->timeStamp = ioMSecs();
	evt->x = theEvent->where.x;
	evt->y = theEvent->where.y;
	evt->numFiles = numberOfItems;
	evt->dragType = dragType;

	/* then the modifiers */
	evt->modifiers = theButtonState;
	/* clean up reserved */
	evt->reserved1 = 0;
	return 1;
}

where dragType is
/* drop files event definition:
    DragEnter - drag operation from OS entered Squeak window
    DragMove  - drag operation from OS moved within Squeak window
    DragLeave - drag operation from OS left Squeak window
    DragDrop  - drag operation dropped contents onto Squeak.
*/
#define DragEnter 1
#define DragMove  2
#define DragLeave 3
#define DragDrop  4

I get all four as events from the macintosh VM, so passing them on as 
Squeak events was easy.

Questions? Email away

>
>tim
>
>--
>Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
>Strange OpCodes: HALT: No-Op

-- 
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================
Custom Macintosh programming & various Smalltalk dialects
PGP Key: DSS/Diff/46FC3BE6
Fingerprint=B22F 7D67 92B7 5D52 72D7  E94A EE69 2D21 46FC 3BE6
===========================================================================





More information about the Squeak-dev mailing list