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