primitiveAsyncFileWriteStart(void) { // AsynchFilePlugin>>#primitiveAsyncFileWriteStart sqInt buffer; sqInt bufferPtr; sqInt bufferSize; sqInt count; AsyncFile *f; sqInt fHandle; sqInt fPosition; sqInt num; sqInt start; sqInt startIndex; fHandle = stackValue(4); fPosition = stackIntegerValue(3); buffer = stackValue(2); start = stackIntegerValue(1); num = stackIntegerValue(0); if (failed()) { return null; } f = asyncFileValueOf(fHandle); if (failed()) { return null; } count = num; startIndex = start; /* in bytes or words */ bufferSize = slotSizeOf(buffer); if (isWords(buffer)) { /* covert word counts to byte counts */ /* covert word counts to byte counts */ count = count * 4; startIndex = ((startIndex - 1) * 4) + 1; bufferSize = bufferSize * 4; } success((startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize)); /* adjust for zero-origin indexing */ bufferPtr = ((((int) (firstIndexableField(buffer)))) + startIndex) - 1; if (!(failed())) { asyncFileWriteStart(f, fPosition, bufferPtr, count); } if (failed()) { return null; } pop(5); return null; }
primitiveAsyncFileReadResult(void) { // AsynchFilePlugin>>#primitiveAsyncFileReadResult sqInt buffer; sqInt bufferPtr; sqInt bufferSize; sqInt count; AsyncFile *f; sqInt fhandle; sqInt num; sqInt r; sqInt start; sqInt startIndex; sqInt _return_value; fhandle = stackValue(3); buffer = stackValue(2); start = stackIntegerValue(1); num = stackIntegerValue(0); if (failed()) { return null; } f = asyncFileValueOf(fhandle); count = num; startIndex = start; /* in bytes or words */ bufferSize = slotSizeOf(buffer); if (isWords(buffer)) { /* covert word counts to byte counts */ /* covert word counts to byte counts */ count = count * 4; startIndex = ((startIndex - 1) * 4) + 1; bufferSize = bufferSize * 4; } success((startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize)); /* adjust for zero-origin indexing */ bufferPtr = ((((int) (firstIndexableField(buffer)))) + startIndex) - 1; if (!(failed())) { r = asyncFileReadResult(f, bufferPtr, count); } _return_value = integerObjectOf(r); if (failed()) { return null; } popthenPush(5, _return_value); return null; }
EXPORT(sqInt) primitiveAsyncFileWriteStart(void) { AsyncFile * f; sqInt count; sqInt startIndex; sqInt bufferSize; char * bufferPtr; sqInt fHandle; sqInt fPosition; sqInt buffer; sqInt start; sqInt num; fHandle = interpreterProxy->stackValue(4); fPosition = interpreterProxy->stackIntegerValue(3); buffer = interpreterProxy->stackValue(2); start = interpreterProxy->stackIntegerValue(1); num = interpreterProxy->stackIntegerValue(0); if (interpreterProxy->failed()) { return null; } f = asyncFileValueOf(fHandle); if (interpreterProxy->failed()) { return null; } count = num; startIndex = start; /* in bytes or words */ bufferSize = interpreterProxy->slotSizeOf(buffer); if (interpreterProxy->isWords(buffer)) { /* convert word counts to byte counts */ count = count * ( 4); startIndex = ((startIndex - 1) * ( 4)) + 1; bufferSize = bufferSize * ( 4); } interpreterProxy->success((startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize)); bufferPtr = (((pointerForOop(buffer)) + ( 4)) + startIndex) - 1; if (!(interpreterProxy->failed())) { asyncFileWriteStart(f, fPosition, bufferPtr, count); } if (interpreterProxy->failed()) { return null; } interpreterProxy->pop(5); return null; }
EXPORT(sqInt) primitiveAsyncFileClose(void) { AsyncFile * f; sqInt fh; fh = interpreterProxy->stackValue(0); if (interpreterProxy->failed()) { return null; } f = asyncFileValueOf(fh); asyncFileClose(f); if (interpreterProxy->failed()) { return null; } interpreterProxy->pop(1); return null; }
EXPORT(sqInt) primitiveAsyncFileReadResult(void) { AsyncFile * f; sqInt count; sqInt startIndex; sqInt bufferSize; sqInt r; char * bufferPtr; sqInt fhandle; sqInt buffer; sqInt start; sqInt num; sqInt _return_value; fhandle = interpreterProxy->stackValue(3); buffer = interpreterProxy->stackValue(2); start = interpreterProxy->stackIntegerValue(1); num = interpreterProxy->stackIntegerValue(0); if (interpreterProxy->failed()) { return null; } f = asyncFileValueOf(fhandle); count = num; startIndex = start; /* in bytes or words */ bufferSize = interpreterProxy->slotSizeOf(buffer); if (interpreterProxy->isWords(buffer)) { /* covert word counts to byte counts */ count = count * 4; startIndex = ((startIndex - 1) * 4) + 1; bufferSize = bufferSize * 4; } interpreterProxy->success((startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize)); bufferPtr = (((pointerForOop(buffer)) + ( 4)) + startIndex) - 1; if (!(interpreterProxy->failed())) { r = asyncFileReadResult(f, bufferPtr, count); } _return_value = interpreterProxy->integerObjectOf(r); if (interpreterProxy->failed()) { return null; } interpreterProxy->popthenPush(5, _return_value); return null; }
primitiveAsyncFileClose(void) { // AsynchFilePlugin>>#primitiveAsyncFileClose AsyncFile *f; sqInt fh; fh = stackValue(0); if (failed()) { return null; } f = asyncFileValueOf(fh); asyncFileClose(f); if (failed()) { return null; } pop(1); return null; }
EXPORT(sqInt) primitiveAsyncFileWriteResult(void) { AsyncFile * f; sqInt r; sqInt fHandle; sqInt _return_value; fHandle = interpreterProxy->stackValue(0); if (interpreterProxy->failed()) { return null; } f = asyncFileValueOf(fHandle); r = asyncFileWriteResult(f); _return_value = interpreterProxy->integerObjectOf(r); if (interpreterProxy->failed()) { return null; } interpreterProxy->popthenPush(2, _return_value); return null; }
EXPORT(sqInt) primitiveAsyncFileReadStart(void) { AsyncFile * f; sqInt fHandle; sqInt fPosition; sqInt count; fHandle = interpreterProxy->stackValue(2); fPosition = interpreterProxy->stackIntegerValue(1); count = interpreterProxy->stackIntegerValue(0); if (interpreterProxy->failed()) { return null; } f = asyncFileValueOf(fHandle); asyncFileReadStart(f, fPosition, count); if (interpreterProxy->failed()) { return null; } interpreterProxy->pop(3); return null; }
primitiveAsyncFileOpen(void) { // AsynchFilePlugin>>#primitiveAsyncFileOpen AsyncFile *f; char *fileName; sqInt fileNameSize; sqInt fOop; sqInt okToOpen; sqInt semaIndex; sqInt writeFlag; success(isBytes(stackValue(2))); fileName = ((char *) (firstIndexableField(stackValue(2)))); writeFlag = booleanValueOf(stackValue(1)); semaIndex = stackIntegerValue(0); if (failed()) { return null; } /* If the security plugin can be loaded, use it to check for permission. If not, assume it's ok */ fileNameSize = slotSizeOf(((int) fileName) - 4); if (sCOAFfn != 0) { okToOpen = ((sqInt (*) (char *, sqInt, sqInt)) sCOAFfn)(fileName, fileNameSize, writeFlag); if (!okToOpen) { primitiveFail(); return null; } } fOop = instantiateClassindexableSize(classByteArray(), sizeof(AsyncFile)); f = asyncFileValueOf(fOop); if (!(failed())) { asyncFileOpen(f, (int)fileName, fileNameSize, writeFlag, semaIndex); } if (failed()) { return null; } popthenPush(4, fOop); return null; }
primitiveAsyncFileWriteResult(void) { // AsynchFilePlugin>>#primitiveAsyncFileWriteResult AsyncFile *f; sqInt fHandle; sqInt r; sqInt _return_value; fHandle = stackValue(0); if (failed()) { return null; } f = asyncFileValueOf(fHandle); r = asyncFileWriteResult(f); _return_value = integerObjectOf(r); if (failed()) { return null; } popthenPush(2, _return_value); return null; }
EXPORT(sqInt) primitiveAsyncFileOpen(void) { AsyncFile * f; sqInt fOop; sqInt okToOpen; sqInt fileNameSize; char *fileName; sqInt writeFlag; sqInt semaIndex; interpreterProxy->success(interpreterProxy->isBytes(interpreterProxy->stackValue(2))); fileName = ((char *) (interpreterProxy->firstIndexableField(interpreterProxy->stackValue(2)))); writeFlag = interpreterProxy->booleanValueOf(interpreterProxy->stackValue(1)); semaIndex = interpreterProxy->stackIntegerValue(0); if (interpreterProxy->failed()) { return null; } /* If the security plugin can be loaded, use it to check for permission. If not, assume it's ok */ fileNameSize = interpreterProxy->slotSizeOf(oopForPointer(fileName) - 4); if (sCOAFfn != 0) { okToOpen = ((sqInt (*) (char *, sqInt, sqInt)) sCOAFfn)(fileName, fileNameSize, writeFlag); if (!(okToOpen)) { interpreterProxy->primitiveFail(); return null; } } fOop = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), sizeof(AsyncFile)); f = asyncFileValueOf(fOop); if (!(interpreterProxy->failed())) { asyncFileOpen(f, (int)fileName, fileNameSize, writeFlag, semaIndex); } if (interpreterProxy->failed()) { return null; } interpreterProxy->popthenPush(4, fOop); return null; }
primitiveAsyncFileReadStart(void) { // AsynchFilePlugin>>#primitiveAsyncFileReadStart sqInt count; AsyncFile *f; sqInt fHandle; sqInt fPosition; fHandle = stackValue(2); fPosition = stackIntegerValue(1); count = stackIntegerValue(0); if (failed()) { return null; } f = asyncFileValueOf(fHandle); asyncFileReadStart(f, fPosition, count); if (failed()) { return null; } pop(3); return null; }