Revision: 3762 Author: lewis Date: 2018-04-14 14:07:56 -0700 (Sat, 14 Apr 2018) Log Message: ----------- ckformat.c from ImageFormat-dtl.30 UnixOSProcessPlugin 4.6.3 from OSProcessPlugin-dtl.44 XDisplayControlPlugin 2.1.7 from VMConstruction-Plugins-XDisplayControlPlugin-dtl.13 Modified Paths: -------------- trunk/src/ckformat.c trunk/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c trunk/src/plugins/XDisplayControlPlugin/XDisplayControlPlugin.c Modified: trunk/src/ckformat.c =================================================================== --- trunk/src/ckformat.c 2018-01-07 18:14:11 UTC (rev 3761) +++ trunk/src/ckformat.c 2018-04-14 21:07:56 UTC (rev 3762) @@ -5,7 +5,7 @@ /* Usage: ckformat imageFileName */ /* --- DO NOT EDIT THIS FILE --- */ -/* --- Automatically generated from class ImageFormat 2017-11-02T23:51:17.239+01:00--- */ +/* --- Automatically generated from class ImageFormat 2018-04-14T17:00:30.957+01:00--- */ /* --- Source code is in package ImageFormat in the VMMaker repository --- */ /* --- DO NOT EDIT THIS FILE --- */ @@ -13,7 +13,7 @@ #include <stdlib.h> #include <string.h> -main(int argc, char **argv) { +int main(int argc, char **argv) { FILE *f; unsigned char buf[8]; int formatNumber; @@ -38,126 +38,126 @@ } { unsigned char b_6502_1[4]= { 0, 0, 25, 102}; - if (strncmp(buf, b_6502_1, 4) == 0) { + if (memcmp(buf, b_6502_1, 4) == 0) { printf("%d\n", 6502); exit(0); } } { unsigned char b_6502_2[4]= { 102, 25, 0, 0}; - if (strncmp(buf, b_6502_2, 4) == 0) { + if (memcmp(buf, b_6502_2, 4) == 0) { printf("%d\n", 6502); exit(0); } } { unsigned char b_6504_3[4]= { 0, 0, 25, 104}; - if (strncmp(buf, b_6504_3, 4) == 0) { + if (memcmp(buf, b_6504_3, 4) == 0) { printf("%d\n", 6504); exit(0); } } { unsigned char b_6504_4[4]= { 104, 25, 0, 0}; - if (strncmp(buf, b_6504_4, 4) == 0) { + if (memcmp(buf, b_6504_4, 4) == 0) { printf("%d\n", 6504); exit(0); } } { unsigned char b_6505_5[4]= { 0, 0, 25, 105}; - if (strncmp(buf, b_6505_5, 4) == 0) { + if (memcmp(buf, b_6505_5, 4) == 0) { printf("%d\n", 6505); exit(0); } } { unsigned char b_6505_6[4]= { 105, 25, 0, 0}; - if (strncmp(buf, b_6505_6, 4) == 0) { + if (memcmp(buf, b_6505_6, 4) == 0) { printf("%d\n", 6505); exit(0); } } { unsigned char b_6521_7[4]= { 0, 0, 25, 121}; - if (strncmp(buf, b_6521_7, 4) == 0) { + if (memcmp(buf, b_6521_7, 4) == 0) { printf("%d\n", 6521); exit(0); } } { unsigned char b_6521_8[4]= { 121, 25, 0, 0}; - if (strncmp(buf, b_6521_8, 4) == 0) { + if (memcmp(buf, b_6521_8, 4) == 0) { printf("%d\n", 6521); exit(0); } } { unsigned char b_68000_9[8]= { 0, 0, 0, 0, 0, 1, 9, 160}; - if (strncmp(buf, b_68000_9, 8) == 0) { + if (memcmp(buf, b_68000_9, 8) == 0) { printf("%d\n", 68000); exit(0); } } { unsigned char b_68000_10[8]= { 160, 9, 1, 0, 0, 0, 0, 0}; - if (strncmp(buf, b_68000_10, 8) == 0) { + if (memcmp(buf, b_68000_10, 8) == 0) { printf("%d\n", 68000); exit(0); } } { unsigned char b_68002_11[8]= { 0, 0, 0, 0, 0, 1, 9, 162}; - if (strncmp(buf, b_68002_11, 8) == 0) { + if (memcmp(buf, b_68002_11, 8) == 0) { printf("%d\n", 68002); exit(0); } } { unsigned char b_68002_12[8]= { 162, 9, 1, 0, 0, 0, 0, 0}; - if (strncmp(buf, b_68002_12, 8) == 0) { + if (memcmp(buf, b_68002_12, 8) == 0) { printf("%d\n", 68002); exit(0); } } { unsigned char b_68003_13[8]= { 0, 0, 0, 0, 0, 1, 9, 163}; - if (strncmp(buf, b_68003_13, 8) == 0) { + if (memcmp(buf, b_68003_13, 8) == 0) { printf("%d\n", 68003); exit(0); } } { unsigned char b_68003_14[8]= { 163, 9, 1, 0, 0, 0, 0, 0}; - if (strncmp(buf, b_68003_14, 8) == 0) { + if (memcmp(buf, b_68003_14, 8) == 0) { printf("%d\n", 68003); exit(0); } } { unsigned char b_68019_15[8]= { 0, 0, 0, 0, 0, 1, 9, 179}; - if (strncmp(buf, b_68019_15, 8) == 0) { + if (memcmp(buf, b_68019_15, 8) == 0) { printf("%d\n", 68019); exit(0); } } { unsigned char b_68019_16[8]= { 179, 9, 1, 0, 0, 0, 0, 0}; - if (strncmp(buf, b_68019_16, 8) == 0) { + if (memcmp(buf, b_68019_16, 8) == 0) { printf("%d\n", 68019); exit(0); } } { unsigned char b_68021_17[8]= { 0, 0, 0, 0, 0, 1, 9, 181}; - if (strncmp(buf, b_68021_17, 8) == 0) { + if (memcmp(buf, b_68021_17, 8) == 0) { printf("%d\n", 68021); exit(0); } } { unsigned char b_68021_18[8]= { 181, 9, 1, 0, 0, 0, 0, 0}; - if (strncmp(buf, b_68021_18, 8) == 0) { + if (memcmp(buf, b_68021_18, 8) == 0) { printf("%d\n", 68021); exit(0); } @@ -172,126 +172,126 @@ } { unsigned char b_6502_1[4]= { 0, 0, 25, 102}; - if (strncmp(buf, b_6502_1, 4) == 0) { + if (memcmp(buf, b_6502_1, 4) == 0) { printf("%d\n", 6502); exit(0); } } { unsigned char b_6502_2[4]= { 102, 25, 0, 0}; - if (strncmp(buf, b_6502_2, 4) == 0) { + if (memcmp(buf, b_6502_2, 4) == 0) { printf("%d\n", 6502); exit(0); } } { unsigned char b_6504_3[4]= { 0, 0, 25, 104}; - if (strncmp(buf, b_6504_3, 4) == 0) { + if (memcmp(buf, b_6504_3, 4) == 0) { printf("%d\n", 6504); exit(0); } } { unsigned char b_6504_4[4]= { 104, 25, 0, 0}; - if (strncmp(buf, b_6504_4, 4) == 0) { + if (memcmp(buf, b_6504_4, 4) == 0) { printf("%d\n", 6504); exit(0); } } { unsigned char b_6505_5[4]= { 0, 0, 25, 105}; - if (strncmp(buf, b_6505_5, 4) == 0) { + if (memcmp(buf, b_6505_5, 4) == 0) { printf("%d\n", 6505); exit(0); } } { unsigned char b_6505_6[4]= { 105, 25, 0, 0}; - if (strncmp(buf, b_6505_6, 4) == 0) { + if (memcmp(buf, b_6505_6, 4) == 0) { printf("%d\n", 6505); exit(0); } } { unsigned char b_6521_7[4]= { 0, 0, 25, 121}; - if (strncmp(buf, b_6521_7, 4) == 0) { + if (memcmp(buf, b_6521_7, 4) == 0) { printf("%d\n", 6521); exit(0); } } { unsigned char b_6521_8[4]= { 121, 25, 0, 0}; - if (strncmp(buf, b_6521_8, 4) == 0) { + if (memcmp(buf, b_6521_8, 4) == 0) { printf("%d\n", 6521); exit(0); } } { unsigned char b_68000_9[8]= { 0, 0, 0, 0, 0, 1, 9, 160}; - if (strncmp(buf, b_68000_9, 8) == 0) { + if (memcmp(buf, b_68000_9, 8) == 0) { printf("%d\n", 68000); exit(0); } } { unsigned char b_68000_10[8]= { 160, 9, 1, 0, 0, 0, 0, 0}; - if (strncmp(buf, b_68000_10, 8) == 0) { + if (memcmp(buf, b_68000_10, 8) == 0) { printf("%d\n", 68000); exit(0); } } { unsigned char b_68002_11[8]= { 0, 0, 0, 0, 0, 1, 9, 162}; - if (strncmp(buf, b_68002_11, 8) == 0) { + if (memcmp(buf, b_68002_11, 8) == 0) { printf("%d\n", 68002); exit(0); } } { unsigned char b_68002_12[8]= { 162, 9, 1, 0, 0, 0, 0, 0}; - if (strncmp(buf, b_68002_12, 8) == 0) { + if (memcmp(buf, b_68002_12, 8) == 0) { printf("%d\n", 68002); exit(0); } } { unsigned char b_68003_13[8]= { 0, 0, 0, 0, 0, 1, 9, 163}; - if (strncmp(buf, b_68003_13, 8) == 0) { + if (memcmp(buf, b_68003_13, 8) == 0) { printf("%d\n", 68003); exit(0); } } { unsigned char b_68003_14[8]= { 163, 9, 1, 0, 0, 0, 0, 0}; - if (strncmp(buf, b_68003_14, 8) == 0) { + if (memcmp(buf, b_68003_14, 8) == 0) { printf("%d\n", 68003); exit(0); } } { unsigned char b_68019_15[8]= { 0, 0, 0, 0, 0, 1, 9, 179}; - if (strncmp(buf, b_68019_15, 8) == 0) { + if (memcmp(buf, b_68019_15, 8) == 0) { printf("%d\n", 68019); exit(0); } } { unsigned char b_68019_16[8]= { 179, 9, 1, 0, 0, 0, 0, 0}; - if (strncmp(buf, b_68019_16, 8) == 0) { + if (memcmp(buf, b_68019_16, 8) == 0) { printf("%d\n", 68019); exit(0); } } { unsigned char b_68021_17[8]= { 0, 0, 0, 0, 0, 1, 9, 181}; - if (strncmp(buf, b_68021_17, 8) == 0) { + if (memcmp(buf, b_68021_17, 8) == 0) { printf("%d\n", 68021); exit(0); } } { unsigned char b_68021_18[8]= { 181, 9, 1, 0, 0, 0, 0, 0}; - if (strncmp(buf, b_68021_18, 8) == 0) { + if (memcmp(buf, b_68021_18, 8) == 0) { printf("%d\n", 68021); exit(0); } Modified: trunk/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c =================================================================== --- trunk/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c 2018-01-07 18:14:11 UTC (rev 3761) +++ trunk/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c 2018-04-14 21:07:56 UTC (rev 3762) @@ -1,6 +1,6 @@ -/* Smalltalk from Squeak4.5 with VMMaker 4.16.3 translated as C source on 22 February 2017 8:18:22 pm */ +/* Smalltalk from Squeak4.5 with VMMaker 4.16.4 translated as C source on 14 April 2018 5:00:30 pm */ /* Automatically generated by - VMPluginCodeGenerator VMMaker-dtl.392 uuid: 7c31d31d-9de0-4f45-89e2-6caa1886f12f + VMPluginCodeGenerator VMMaker-dtl.395 uuid: e4b19e32-5246-4f48-b97d-30a443d21c6f from UnixOSProcessPlugin * uuid: nil */ @@ -36,12 +36,11 @@ #endif #include <sys/types.h> /* D T Lewis - UnixOSProcessPlugin.c translated from class - UnixOSProcessPlugin of OSProcessPlugin version 4.6.2 */ + UnixOSProcessPlugin of OSProcessPlugin version 4.6.3 */ #include <sys/time.h> #include <sys/wait.h> #include <signal.h> #include <unistd.h> -#include <stdlib.h> #include <fcntl.h> #include <signal.h> #include <pthread.h> @@ -104,8 +103,9 @@ EXPORT(sqInt) primitiveArgumentAt(void); EXPORT(sqInt) primitiveCanReceiveSignals(sqInt anIntegerPid); EXPORT(sqInt) primitiveChdir(void); +EXPORT(sqInt) primitiveConnectToFile(void); +EXPORT(sqInt) primitiveConnectoToFileDescriptor(void); EXPORT(sqInt) primitiveCreatePipe(void); -EXPORT(sqInt) primitiveCreatePipeWithSessionIdentifier(void); EXPORT(sqInt) primitiveDup(sqInt fileDescriptor); EXPORT(sqInt) primitiveDupTo(sqInt oldFileDescriptor, sqInt newFileDescriptor); EXPORT(sqInt) primitiveEnvironmentAt(void); @@ -188,7 +188,6 @@ static sqInt sandboxSecurity(void); static sqInt securityHeurisitic(void); static void sendSignalToPids(void); -static SESSIONIDENTIFIERTYPE sessionIdentifierFrom(sqInt aByteArray); static SESSIONIDENTIFIERTYPE sessionIdentifierFromSqFile(SQFile *sqFile); #pragma export on EXPORT(sqInt) setInterpreter(struct VirtualMachine*anInterpreter); @@ -216,6 +215,7 @@ static sqInt sizeOfInt(void); static sqInt sizeOfPointer(void); static sqInt sizeOfSession(void); +static sqInt sqFileFromforWriteisStdio(FILEHANDLETYPE filehandle, sqInt writeFlag, sqInt isInputOutputOrErrorStream); static sqInt stringFromCString(const char *aCString); static char * transientCStringFromString(sqInt aString); static int unixFileNumber(FILEHANDLETYPE fileHandle); @@ -228,9 +228,9 @@ struct VirtualMachine* interpreterProxy; static const char *moduleName = #ifdef SQUEAK_BUILTIN_PLUGIN - "UnixOSProcessPlugin 22 February 2017 (i)" + "UnixOSProcessPlugin 14 April 2018 (i)" #else - "UnixOSProcessPlugin 22 February 2017 (e)" + "UnixOSProcessPlugin 14 April 2018 (e)" #endif ; static void *originalSigHandlers[NSIG + 1]; @@ -881,104 +881,106 @@ } -/* Create a pipe, and answer an array of two file handles for the pipe writer and reader. - The readerIOStream and writerIOStream variables represent the low level pipe streams, - which will be of type (FILE *) or HANDLE, depending on what the FilePlugin support - code is using to represent file streams. FILEHANDLETYPE is defined in my subclasses - in the #declareCVarsIn: class method. */ +/* Given a stdio file pointer passed as a byte array, create a SQFile struct. Answer + a ByteArray representation of the SQFile. Parameters are the ByteArray representation + of the FILE* pointer to the stdio stream, and a boolean writeable flag. Answers a byte + array can be used as the fileID field of a file stream. Intended for use with FFI calls that + may obtain a FILE* that is to be used in a FileStream. */ -EXPORT(sqInt) primitiveCreatePipe(void) { - sqInt arrayResult; - sqInt reader; - FILEHANDLETYPE readerIOStream; - FILEHANDLETYPE *readerIOStreamPtr; - SQFile *readerPtr; - SESSIONIDENTIFIERTYPE thisSession; - sqInt writer; - FILEHANDLETYPE writerIOStream; - FILEHANDLETYPE *writerIOStreamPtr; - SQFile *writerPtr; +EXPORT(sqInt) primitiveConnectToFile(void) { + FILE *filePointerBytes; + sqInt filePointerOop; + sqInt sqFile; + sqInt writeFlag; + writeFlag = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0)); + filePointerOop = interpreterProxy->stackValue(1); + if (!((interpreterProxy->isBytes(filePointerOop)) && ((interpreterProxy->byteSizeOf(filePointerOop)) == (sizeOfPointer())))) { + return interpreterProxy->primitiveFailFor(PrimErrBadArgument); + } + filePointerBytes = interpreterProxy->firstIndexableField(filePointerOop); + if (interpreterProxy->failed()) { + return interpreterProxy->primitiveFailFor(PrimErrBadArgument); + } + sqFile = sqFileFromforWriteisStdio(filePointerBytes, writeFlag, 0); + interpreterProxy->popthenPush(3, sqFile); + return null; +} - /* Create the anonymous OS pipe */ - thisSession = interpreterProxy->getThisSessionID(); - readerIOStreamPtr = &readerIOStream; - writerIOStreamPtr = &writerIOStream; - if (!(createPipeForReaderwriter(readerIOStreamPtr, writerIOStreamPtr))) { - return interpreterProxy->primitiveFail(); +/* Given an integer Unix file descriptor or Windows handle, create a SQFile struct. + Answer a ByteArray representation of the SQFile. Parameters are an integer representing + a file descriptor or handle, and a boolean writeable flag. Answers a byte array that can + be used as the fileID field of a file stream. Intended for use with FFI calls that may + obtain a file handle or descriptor that is to be used in a FileStream. */ + +EXPORT(sqInt) primitiveConnectoToFileDescriptor(void) { + sqInt fd; + sqInt fdPointer; + sqInt sqFile; + FILEHANDLETYPE sqFileHandle; + sqInt writeFlag; + FILE *file; + FILEHANDLETYPE handle; + FILEHANDLETYPE sqFileHandle1; + + writeFlag = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(0)); + fdPointer = interpreterProxy->stackValue(1); + if (!((fdPointer & 1))) { + return interpreterProxy->primitiveFailFor(PrimErrBadArgument); } - writer = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), sizeof(SQFile)); - writerPtr = interpreterProxy->arrayValueOf(writer); - writerPtr->file = writerIOStream; - writerPtr->sessionID = thisSession; - writerPtr->writable = 1; - writerPtr->lastOp = 0; - interpreterProxy->pushRemappableOop(writer); - reader = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), sizeof(SQFile)); - readerPtr = interpreterProxy->arrayValueOf(reader); - readerPtr->file = readerIOStream; - readerPtr->sessionID = thisSession; - readerPtr->writable = 0; - readerPtr->lastOp = 0; - interpreterProxy->pushRemappableOop(reader); - arrayResult = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classArray(), 2); - interpreterProxy->stObjectatput(arrayResult, 1, interpreterProxy->popRemappableOop()); - interpreterProxy->stObjectatput(arrayResult, 2, interpreterProxy->popRemappableOop()); - interpreterProxy->pop(1); - interpreterProxy->push(arrayResult); + fd = (fdPointer >> 1); + /* begin sqHandleFrom:forWrite: */ + handle = fd; + if (writeFlag) { + file = fdopen(handle, "wb"); + } else { + file = fdopen(handle, "rb"); + } + if (!(file)) { + primitiveFailFor(PrimErrBadArgument); + } + sqFileHandle1 = file; + sqFileHandle = sqFileHandle1; + sqFile = sqFileFromforWriteisStdio(sqFileHandle, writeFlag, 0); + interpreterProxy->popthenPush(3, sqFile); return null; } /* Create a pipe, and answer an array of two file handles for the pipe writer and reader. - The session identifier is passed as the parameter to this primitive. Use this variant - if the session identifier is not available directly in the VM (as may be the case if - it is not possible to link from this plugin to a variable elsewhere in the VM). The readerIOStream and writerIOStream variables represent the low level pipe streams, which will be of type (FILE *) or HANDLE, depending on what the FilePlugin support code is using to represent file streams. FILEHANDLETYPE is defined in my subclasses in the #declareCVarsIn: class method. */ -EXPORT(sqInt) primitiveCreatePipeWithSessionIdentifier(void) { +EXPORT(sqInt) primitiveCreatePipe(void) { sqInt arrayResult; sqInt reader; FILEHANDLETYPE readerIOStream; FILEHANDLETYPE *readerIOStreamPtr; - SQFile *readerPtr; SESSIONIDENTIFIERTYPE thisSession; sqInt writer; FILEHANDLETYPE writerIOStream; FILEHANDLETYPE *writerIOStreamPtr; - SQFile *writerPtr; /* Create the anonymous OS pipe */ - thisSession = sessionIdentifierFrom(interpreterProxy->stackObjectValue(0)); + thisSession = interpreterProxy->getThisSessionID(); readerIOStreamPtr = &readerIOStream; writerIOStreamPtr = &writerIOStream; if (!(createPipeForReaderwriter(readerIOStreamPtr, writerIOStreamPtr))) { return interpreterProxy->primitiveFail(); } - writer = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), sizeof(SQFile)); - writerPtr = interpreterProxy->arrayValueOf(writer); - writerPtr->file = writerIOStream; - writerPtr->sessionID = thisSession; - writerPtr->writable = 1; - writerPtr->lastOp = 0; + writer = sqFileFromforWriteisStdio(writerIOStream, 1, 0); interpreterProxy->pushRemappableOop(writer); - reader = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), sizeof(SQFile)); - readerPtr = interpreterProxy->arrayValueOf(reader); - readerPtr->file = readerIOStream; - readerPtr->sessionID = thisSession; - readerPtr->writable = 0; - readerPtr->lastOp = 0; + reader = sqFileFromforWriteisStdio(readerIOStream, 0, 0); interpreterProxy->pushRemappableOop(reader); arrayResult = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classArray(), 2); interpreterProxy->stObjectatput(arrayResult, 1, interpreterProxy->popRemappableOop()); interpreterProxy->stObjectatput(arrayResult, 2, interpreterProxy->popRemappableOop()); - interpreterProxy->pop(2); + interpreterProxy->pop(1); interpreterProxy->push(arrayResult); return null; } @@ -1630,19 +1632,10 @@ /* Answer the file handle for standard error of my OS process */ EXPORT(sqInt) primitiveGetStdErrHandle(void) { - SQFile *file; - sqInt fileOop; - SESSIONIDENTIFIERTYPE thisSession; + sqInt sqFile; - fileOop = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), sizeof(SQFile)); - file = interpreterProxy->arrayValueOf(fileOop); - thisSession = interpreterProxy->getThisSessionID(); - file->file = stderr; - file->sessionID = thisSession; - file->writable = 1; - file->lastOp = 0; - interpreterProxy->pop(1); - interpreterProxy->push(fileOop); + sqFile = sqFileFromforWriteisStdio(stderr, 1, 0); + interpreterProxy->popthenPush(1, sqFile); return null; } @@ -1650,19 +1643,10 @@ /* Answer the file handle for standard input of my OS process */ EXPORT(sqInt) primitiveGetStdInHandle(void) { - SQFile *file; - sqInt fileOop; - SESSIONIDENTIFIERTYPE thisSession; + sqInt sqFile; - fileOop = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), sizeof(SQFile)); - file = interpreterProxy->arrayValueOf(fileOop); - thisSession = interpreterProxy->getThisSessionID(); - file->file = stdin; - file->sessionID = thisSession; - file->writable = 0; - file->lastOp = 0; - interpreterProxy->pop(1); - interpreterProxy->push(fileOop); + sqFile = sqFileFromforWriteisStdio(stdin, 0, 0); + interpreterProxy->popthenPush(1, sqFile); return null; } @@ -1670,19 +1654,10 @@ /* Answer the file handle for standard output of my OS process */ EXPORT(sqInt) primitiveGetStdOutHandle(void) { - SQFile *file; - sqInt fileOop; - SESSIONIDENTIFIERTYPE thisSession; + sqInt sqFile; - fileOop = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), sizeof(SQFile)); - file = interpreterProxy->arrayValueOf(fileOop); - thisSession = interpreterProxy->getThisSessionID(); - file->file = stdout; - file->sessionID = thisSession; - file->writable = 1; - file->lastOp = 0; - interpreterProxy->pop(1); - interpreterProxy->push(fileOop); + sqFile = sqFileFromforWriteisStdio(stdout, 1, 0); + interpreterProxy->popthenPush(1, sqFile); return null; } @@ -1839,14 +1814,12 @@ for owner only. */ EXPORT(sqInt) primitiveMkstemp(void) { - SQFile *file; sqInt fileDescriptor; - sqInt fileOop; FILEHANDLETYPE handle; sqInt sourceString; + sqInt sqFile; char *template; sqInt templateString; - sqInt thisSession; sourceString = interpreterProxy->stackObjectValue(0); if (!(interpreterProxy->isWordsOrBytes(sourceString))) { @@ -1859,18 +1832,9 @@ perror("mkstemp"); return interpreterProxy->primitiveFail(); } else { - - /* A SQFile data structure for the file descriptor */ - - fileOop = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), sizeof(SQFile)); - file = interpreterProxy->arrayValueOf(fileOop); - thisSession = interpreterProxy->getThisSessionID(); handle = fdopen(fileDescriptor, "r+"); - file->file = handle; - file->sessionID = thisSession; - file->writable = 1; - file->lastOp = 0; - interpreterProxy->popthenPush(2, fileOop); + sqFile = sqFileFromforWriteisStdio(handle, 1, 0); + interpreterProxy->popthenPush(2, sqFile); } return null; } @@ -3062,28 +3026,6 @@ } -/* Answer a session ID represented by aByteArray. The session ID is used in - the SQFile structure. If that data structure changes, we should see compiler - warnings about type mismatch with SESSIONIDENTIFIERTYPE. */ - -static SESSIONIDENTIFIERTYPE sessionIdentifierFrom(sqInt aByteArray) { - sqInt idx; - unsigned char *session; - union {SESSIONIDENTIFIERTYPE session; unsigned char bytes[sizeof(SESSIONIDENTIFIERTYPE)];} sessionUnion; - - if (!((interpreterProxy->isBytes(aByteArray)) && ((interpreterProxy->stSizeOf(aByteArray)) == (sizeOfSession())))) { - return null; - } - session = interpreterProxy->arrayValueOf(aByteArray); - idx = 0; - while (idx < (sizeOfSession())) { - sessionUnion.bytes[idx] = session[idx]; - idx += 1; - } - return sessionUnion.session; -} - - /* Answer the session identifier from a SQFile structure. For a valid file reference, this identifier will match the session identifier supplied by the interpreter. */ @@ -3321,6 +3263,28 @@ } +/* Answer a SQFile byte array for filehandle. The isInputOutputOrErrorStream + parameter is possibly useful for Windows but is otherwise best ignored. */ + +static sqInt sqFileFromforWriteisStdio(FILEHANDLETYPE filehandle, sqInt writeFlag, sqInt isInputOutputOrErrorStream) { + char isStdioStream; + sqInt sqFile; + SQFile *sqFilePtr; + SESSIONIDENTIFIERTYPE thisSession; + + isStdioStream = ((char) isInputOutputOrErrorStream); + thisSession = interpreterProxy->getThisSessionID(); + sqFile = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), sizeof(SQFile)); + sqFilePtr = interpreterProxy->arrayValueOf(sqFile); + sqFilePtr->file = filehandle; + sqFilePtr->sessionID = thisSession; + sqFilePtr->writable = writeFlag; + sqFilePtr->lastOp = 0; + sqFilePtr->isStdioStream = isStdioStream; + return sqFile; +} + + /* Answer a new String copied from a null-terminated C string. Caution: This may invoke the garbage collector. */ @@ -3387,7 +3351,7 @@ /* Answer a string identifying the version level for this plugin. */ static char * versionString(void) { - static char version[]= "4.6.2"; + static char version[]= "4.6.3"; return version; } @@ -3469,8 +3433,9 @@ {"UnixOSProcessPlugin", "primitiveSizeOfPointer", (void*)primitiveSizeOfPointer}, {"UnixOSProcessPlugin", "primitiveDupTo", (void*)primitiveDupTo}, {"UnixOSProcessPlugin", "primitiveSigChldNumber", (void*)primitiveSigChldNumber}, - {"UnixOSProcessPlugin", "primitiveGetStdInHandle", (void*)primitiveGetStdInHandle}, + {"UnixOSProcessPlugin", "primitiveConnectoToFileDescriptor", (void*)primitiveConnectoToFileDescriptor}, {"UnixOSProcessPlugin", "primitiveCreatePipe", (void*)primitiveCreatePipe}, + {"UnixOSProcessPlugin", "primitiveGetStdInHandle", (void*)primitiveGetStdInHandle}, {"UnixOSProcessPlugin", "primitiveUnlockFileRegion", (void*)primitiveUnlockFileRegion}, {"UnixOSProcessPlugin", "primitiveModuleName", (void*)primitiveModuleName}, {"UnixOSProcessPlugin", "primitiveFixPointersInArrayOfStrings", (void*)primitiveFixPointersInArrayOfStrings}, @@ -3482,7 +3447,7 @@ {"UnixOSProcessPlugin", "primitiveEnvironmentAtSymbol", (void*)primitiveEnvironmentAtSymbol}, {"UnixOSProcessPlugin", "primitiveDup", (void*)primitiveDup}, {"UnixOSProcessPlugin", "primitiveSetPGrp", (void*)primitiveSetPGrp}, - {"UnixOSProcessPlugin", "primitiveCreatePipeWithSessionIdentifier", (void*)primitiveCreatePipeWithSessionIdentifier}, + {"UnixOSProcessPlugin", "primitiveConnectToFile", (void*)primitiveConnectToFile}, {"UnixOSProcessPlugin", "getModuleName", (void*)getModuleName}, {NULL, NULL, NULL} }; Modified: trunk/src/plugins/XDisplayControlPlugin/XDisplayControlPlugin.c =================================================================== --- trunk/src/plugins/XDisplayControlPlugin/XDisplayControlPlugin.c 2018-01-07 18:14:11 UTC (rev 3761) +++ trunk/src/plugins/XDisplayControlPlugin/XDisplayControlPlugin.c 2018-04-14 21:07:56 UTC (rev 3762) @@ -1,10 +1,10 @@ -/* Smalltalk from Squeak4.5 with VMMaker 4.16.1 translated as C source on 2 January 2017 8:53:17 pm */ +/* Smalltalk from Squeak4.5 with VMMaker 4.16.4 translated as C source on 14 April 2018 5:00:30 pm */ /* Automatically generated by - VMPluginCodeGenerator VMMaker-dtl.390 uuid: 1fb628a6-18d2-4d86-b651-dc3b3d0cce69 + VMPluginCodeGenerator VMMaker-dtl.395 uuid: e4b19e32-5246-4f48-b97d-30a443d21c6f from - XDisplayControlPlugin * VMConstruction-Plugins-XDisplayControlPlugin-dtl.10 uuid: 2fadcdb8-69b6-4af0-bd02-fc59400ebd07 + XDisplayControlPlugin VMConstruction-Plugins-XDisplayControlPlugin-dtl.14 uuid: 9d884490-b489-4fa8-9289-65fe2b2f6c59 */ -static char __buildInfo[] = "XDisplayControlPlugin * VMConstruction-Plugins-XDisplayControlPlugin-dtl.10 uuid: 2fadcdb8-69b6-4af0-bd02-fc59400ebd07 " __DATE__ ; +static char __buildInfo[] = "XDisplayControlPlugin VMConstruction-Plugins-XDisplayControlPlugin-dtl.14 uuid: 9d884490-b489-4fa8-9289-65fe2b2f6c59 " __DATE__ ; @@ -77,9 +77,9 @@ struct VirtualMachine* interpreterProxy; static const char *moduleName = #ifdef SQUEAK_BUILTIN_PLUGIN - "XDisplayControlPlugin 2 January 2017 (i)" + "XDisplayControlPlugin 14 April 2018 (i)" #else - "XDisplayControlPlugin 2 January 2017 (e)" + "XDisplayControlPlugin 14 April 2018 (e)" #endif ; static int osprocessSandboxSecurity; @@ -311,23 +311,20 @@ if (sCWIfn == 0) { return 0; } - canWriteImage = ((int (*) (void)) sCWIfn)(); + canWriteImage = ((sqInt (*) (void)) sCWIfn)(); sHFAfn = interpreterProxy->ioLoadFunctionFrom("secHasFileAccess", "SecurityPlugin"); if (sHFAfn == 0) { return 0; } - hasFileAccess = ((int (*) (void)) sHFAfn)(); + hasFileAccess = ((sqInt (*) (void)) sHFAfn)(); sHSAfn = interpreterProxy->ioLoadFunctionFrom("secHasSocketAccess", "SecurityPlugin"); if (sHSAfn == 0) { return 0; } - hasSocketAccess = ((int (*) (void)) sHSAfn)(); - if ((canWriteImage && (hasFileAccess)) && (hasSocketAccess)) { - return 0; - } else { - return 1; - } - return null; + hasSocketAccess = ((sqInt (*) (void)) sHSAfn)(); + return ((canWriteImage && (hasFileAccess)) && (hasSocketAccess) + ? 0 + : 1); } |
Free forum by Nabble | Edit this page |