primitiveSerialPortRead(void) { // SerialPlugin>>#primitiveSerialPortRead char *array; sqInt arrayPtr; sqInt bytesRead; sqInt count; sqInt portNum; sqInt startIndex; sqInt _return_value; portNum = stackIntegerValue(3); success(isBytes(stackValue(2))); array = ((char *) (firstIndexableField(stackValue(2)))); startIndex = stackIntegerValue(1); count = stackIntegerValue(0); if (failed()) { return null; } success((startIndex >= 1) && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(long)(array) - 4))))); arrayPtr = ((((sqInt)array)) + startIndex) - 1; bytesRead = serialPortReadInto( portNum, count, arrayPtr); _return_value = integerObjectOf(bytesRead); if (failed()) { return null; } popthenPush(5, _return_value); return null; }
primitiveSetStringProperty(void) { sqInt handle; sqInt propID; sqInt result; sqInt srcLen; sqInt srcOop; char *srcPtr; if (!((methodArgumentCount()) == 3)) { return primitiveFail(); } srcOop = stackObjectValue(0); propID = stackIntegerValue(1); handle = stackIntegerValue(2); if (failed()) { return null; } if (!(isBytes(srcOop))) { return primitiveFail(); } srcPtr = firstIndexableField(srcOop); srcLen = byteSizeOf(srcOop); result = sqSetStringPropertySSL(handle, propID, srcPtr, srcLen); if (!result) { return primitiveFail(); } if (failed()) { return null; } pop(methodArgumentCount()); return 0; }
primitiveSerialPortWrite(void) { char *array; char * arrayPtr; sqInt bytesWritten; sqInt count; sqInt portNum; sqInt startIndex; sqInt _return_value; bytesWritten = 0; portNum = stackIntegerValue(3); success(isBytes(stackValue(2))); array = ((char *) (firstIndexableField(stackValue(2)))); startIndex = stackIntegerValue(1); count = stackIntegerValue(0); if (failed()) { return null; } success((startIndex >= 1) && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize))))); if (!(failed())) { arrayPtr = (array + startIndex) - 1; bytesWritten = serialPortWriteFrom(portNum, count, arrayPtr); } if (failed()) { return null; } _return_value = integerObjectOf(bytesWritten); popthenPush(5, _return_value); return null; }
primitiveSoundInsertSamples(void) { // SoundPlugin>>#primitiveSoundInsertSamples unsigned *buf; sqInt frameCount; sqInt framesPlayed; sqInt leadTime; sqInt _return_value; frameCount = stackIntegerValue(2); success(isWords(stackValue(1))); buf = ((unsigned *) (firstIndexableField(stackValue(1)))); leadTime = stackIntegerValue(0); if (failed()) { return null; } success(frameCount <= (slotSizeOf(((sqInt)(long)(buf) - BaseHeaderSize)))); if (!(failed())) { framesPlayed = snd_InsertSamplesFromLeadTime(frameCount, (void *)buf, leadTime); success(framesPlayed >= 0); } _return_value = positive32BitIntegerFor(framesPlayed); if (failed()) { return null; } popthenPush(4, _return_value); return null; }
primitiveSetFog(void) { // B3DAcceleratorPlugin>>#primitiveSetFog double density; sqInt fogType; sqInt handle; sqInt result; sqInt rgba; double start; double stop; if (!((methodArgumentCount()) == 6)) { return primitiveFail(); } rgba = positive32BitValueOf(stackValue(0)); stop = floatValueOf(stackValue(1)); start = floatValueOf(stackValue(2)); density = floatValueOf(stackValue(3)); fogType = stackIntegerValue(4); handle = stackIntegerValue(5); if (failed()) { return null; } result = b3dxSetFog(handle, fogType, density, start, stop, rgba); if (!result) { return primitiveFail(); } return pop(6); }
primitiveSoundPlaySamples(void) { // SoundPlugin>>#primitiveSoundPlaySamples unsigned *buf; sqInt frameCount; sqInt framesPlayed; sqInt startIndex; sqInt _return_value; frameCount = stackIntegerValue(2); success(isWords(stackValue(1))); buf = ((unsigned *) (firstIndexableField(stackValue(1)))); startIndex = stackIntegerValue(0); if (failed()) { return null; } success((startIndex >= 1) && (((startIndex + frameCount) - 1) <= (slotSizeOf(((sqInt)(long)(buf) - BaseHeaderSize))))); if (!(failed())) { framesPlayed = snd_PlaySamplesFromAtLength(frameCount, (void *)buf, startIndex - 1); success(framesPlayed >= 0); } _return_value = positive32BitIntegerFor(framesPlayed); if (failed()) { return null; } popthenPush(4, _return_value); return null; }
primitiveCreateRendererFlags(void) { // B3DAcceleratorPlugin>>#primitiveCreateRendererFlags sqInt flags; sqInt h; sqInt result; sqInt w; sqInt x; sqInt y; if (!((methodArgumentCount()) == 5)) { return primitiveFail(); } h = stackIntegerValue(0); w = stackIntegerValue(1); y = stackIntegerValue(2); x = stackIntegerValue(3); flags = stackIntegerValue(4); if (failed()) { return null; } result = b3dxCreateRendererFlags(x, y, w, h, flags); if (result < 0) { return primitiveFail(); } pop(6); return pushInteger(result); }
primitiveAllocateTexture(void) { // B3DAcceleratorPlugin>>#primitiveAllocateTexture sqInt d; sqInt h; sqInt renderer; sqInt result; sqInt w; if (!((methodArgumentCount()) == 4)) { return primitiveFail(); } h = stackIntegerValue(0); w = stackIntegerValue(1); d = stackIntegerValue(2); renderer = stackIntegerValue(3); if (failed()) { return null; } result = b3dxAllocateTexture(renderer, w, h, d); if (result == -1) { return primitiveFail(); } pop(5); return pushInteger(result); }
primitiveCreateRenderer(void) { // B3DAcceleratorPlugin>>#primitiveCreateRenderer sqInt allowHardware; sqInt allowSoftware; sqInt h; sqInt result; sqInt w; sqInt x; sqInt y; if (!((methodArgumentCount()) == 6)) { return primitiveFail(); } h = stackIntegerValue(0); w = stackIntegerValue(1); y = stackIntegerValue(2); x = stackIntegerValue(3); allowHardware = booleanValueOf(stackValue(4)); allowSoftware = booleanValueOf(stackValue(5)); if (failed()) { return null; } result = b3dxCreateRenderer(allowSoftware, allowHardware, x, y, w, h); if (result < 0) { return primitiveFail(); } pop(7); return pushInteger(result); }
primitiveAioEnable(void) { static int eventSemaphoreIndices[FD_SETSIZE]; sqInt externalObject; sqInt fd; sqInt flags; sqInt semaIndex; if ((nilObject()) == (stackValue(2))) { return primitiveFail(); } fd = stackIntegerValue(2); if (fd < 0) { return primitiveFail(); } semaIndex = stackIntegerValue(1); eventSemaphoreIndices[semaIndex] = semaIndex; externalObject = stackObjectValue(0); if (externalObject == (trueObject())) { flags = AIO_EXT; } else { flags = 0; } aioEnable(fd, &(eventSemaphoreIndices[semaIndex]), flags); pop(4); pushInteger(semaIndex); return 0; }
primitiveSetViewport(void) { // B3DAcceleratorPlugin>>#primitiveSetViewport sqInt h; sqInt handle; sqInt result; sqInt w; sqInt x; sqInt y; if (!((methodArgumentCount()) == 5)) { return primitiveFail(); } h = stackIntegerValue(0); w = stackIntegerValue(1); y = stackIntegerValue(2); x = stackIntegerValue(3); handle = stackIntegerValue(4); if (failed()) { return null; } result = b3dxSetViewport(handle, x, y, w, h); if (!result) { return primitiveFail(); } return pop(5); }
primitiveSetIntProperty(void) { sqInt handle; sqInt propID; sqInt result; sqInt value; if (!((methodArgumentCount()) == 3)) { return primitiveFail(); } value = signed32BitValueOf(stackValue(0)); propID = stackIntegerValue(1); handle = stackIntegerValue(2); if (failed()) { return null; } result = sqSetIntPropertySSL(handle, propID, value); if (!result) { return primitiveFail(); } if (failed()) { return null; } pop(methodArgumentCount()); return 0; }
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; }
primitiveSerialPortOpen(void) { sqInt baudRate; sqInt dataBits; sqInt inFlowControl; sqInt outFlowControl; sqInt parityType; sqInt portNum; sqInt stopBitsType; sqInt xOffChar; sqInt xOnChar; portNum = stackIntegerValue(8); baudRate = stackIntegerValue(7); stopBitsType = stackIntegerValue(6); parityType = stackIntegerValue(5); dataBits = stackIntegerValue(4); inFlowControl = stackIntegerValue(3); outFlowControl = stackIntegerValue(2); xOnChar = stackIntegerValue(1); xOffChar = stackIntegerValue(0); if (failed()) { return null; } serialPortOpen( portNum, baudRate, stopBitsType, parityType, dataBits, inFlowControl, outFlowControl, xOnChar, xOffChar); if (failed()) { return null; } pop(9); return null; }
primPCREExecfromto(void) { sqInt extraObj; sqInt fromInteger; sqInt length; int *matchSpacePtr; sqInt matchSpaceSize; sqInt result; char *searchBuffer; sqInt searchObject; sqInt toInteger; /* Load Parameters */ toInteger = stackIntegerValue(0); fromInteger = stackIntegerValue(1); searchObject = stackObjectValue(2); searchBuffer = arrayValueOf(searchObject); length = byteSizeOf(searchObject); /* begin loadRcvrFromStackAt: */ rcvr = stackObjectValue(3); success(1 <= fromInteger); success(toInteger <= length); /* Smalltalk offsets are 1-based */ fromInteger -= 1; success(fromInteger <= toInteger); length = toInteger - fromInteger; /* Load Instance Variables */ searchBuffer += fromInteger; pcrePtr = ((sqInt) (fetchArrayofObject(2, rcvr))); /* begin rcvrExtraPtr */ extraObj = fetchPointerofObject(3, rcvr); extraPtr = ((sqInt) ((!(extraObj == (nilObject())) ? arrayValueOf(extraObj) : 0))); matchFlags = fetchIntegerofObject(6, rcvr); matchSpacePtr = ((int *) (fetchArrayofObject(7, rcvr))); matchSpaceSize = (byteSizeOf(fetchPointerofObject(7, rcvr))) / 4; if (failed()) { return null; } result = pcre_exec((pcre *)pcrePtr, (pcre_extra *)extraPtr, searchBuffer, length, 0, matchFlags, matchSpacePtr, matchSpaceSize); pop(4); pushInteger(result); return 0; }
primitiveAtPut(void) { // FloatArrayPlugin>>#primitiveAtPut float *floatPtr; double floatValue; sqInt index; sqInt rcvr; sqInt value; value = stackValue(0); if (isIntegerObject(value)) { floatValue = ((double) (integerValueOf(value)) ); } else { floatValue = floatValueOf(value); } index = stackIntegerValue(1); rcvr = stackObjectValue(2); if (failed()) { return null; } success(isWords(rcvr)); success((index > 0) && (index <= (slotSizeOf(rcvr)))); if (failed()) { return null; } floatPtr = firstIndexableField(rcvr); floatPtr[index - 1] = (((float) floatValue)); if (!(failed())) { popthenPush(3, value); } }
primitiveGetIntProperty(void) { // B3DAcceleratorPlugin>>#primitiveGetIntProperty sqInt handle; sqInt prop; sqInt result; if (!((methodArgumentCount()) == 2)) { return primitiveFail(); } prop = stackIntegerValue(0); handle = stackIntegerValue(1); result = b3dxGetIntProperty(handle, prop); pop(3); return pushInteger(result); }
/* win32JoystickDebugPrintRawValues: Print the raw values of a readout of the specified joystick. */ EXPORT(int) win32JoystickDebugPrintRawValues(void) { int index, err; JOYINFO info; if(methodArgumentCount() != 1) return primitiveFail(); index = stackIntegerValue(0); if(failed()) return 0; if(index < 1 || index > 2) return primitiveFail(); warnPrintf(TEXT("Raw joystick values (%d):\n"), index); err = joyGetPos(index-1, &info); if(err != JOYERR_NOERROR) { if(err == MMSYSERR_NODRIVER) warnPrintf(TEXT("\t<no driver present>\n\n")); else if(err == MMSYSERR_INVALPARAM) warnPrintf(TEXT("\t<invalid param in joyGetPos()>\n\n")); else if(err == MMSYSERR_BADDEVICEID) warnPrintf(TEXT("\t<bad device id>\n\n")); else if(err == JOYERR_UNPLUGGED) warnPrintf(TEXT("\t<joystick unplugged>\n\n")); else warnPrintf(TEXT("\t<unknown error: %d>\n\n"), err); } else { warnPrintf(TEXT("\tX: %d\n"), info.wXpos); warnPrintf(TEXT("\tY: %d\n"), info.wYpos); warnPrintf(TEXT("\tZ: %d\n"), info.wZpos); warnPrintf(TEXT("\tButtons: %x\n"), info.wButtons); } pop(1); /* Leave rcvr on stack */ return 1; }
primitiveAtPut(void) { float *floatPtr; double floatValue; sqInt index; sqInt rcvr; sqInt value; value = stackValue(0); if (isIntegerObject(value)) { floatValue = ((double) (integerValueOf(value)) ); } else { floatValue = floatValueOf(value); } index = stackIntegerValue(1); rcvr = stackValue(2); if (!((!(failed())) && ((isWords(rcvr)) && ((index > 0) && (index <= (slotSizeOf(rcvr))))))) { return primitiveFail(); } floatPtr = firstIndexableField(rcvr); floatPtr[index - 1] = (((float) floatValue)); popthenPush(3, value); return 0; }
/* primitivePluginRequestUrlStream: url with: semaIndex Request a URL from the browser. Signal semaIndex when the result of the request can be queried. Returns a handle used in subsequent calls to plugin stream functions. Note: A request id is the index into requests[]. */ int display_primitivePluginRequestURLStream() { sqStreamRequest *req; int id, url, length, semaIndex; if (!inBrowser) return primitiveFail(); DPRINT("VM: primitivePluginRequestURLStream()\n"); for (id=0; id<MAX_REQUESTS; id++) { if (!requests[id]) break; } if (id >= MAX_REQUESTS) return primitiveFail(); semaIndex= stackIntegerValue(0); url= stackObjectValue(1); if (failed()) return 0; if (!isBytes(url)) return primitiveFail(); req= calloc(1, sizeof(sqStreamRequest)); if (!req) return primitiveFail(); req->localName= NULL; req->semaIndex= semaIndex; req->state= -1; requests[id]= req; length= byteSizeOf(url); browserGetURLRequest(id, firstIndexableField(url), length, NULL, 0); pop(3); push(positive32BitIntegerFor(id)); DPRINT("VM: request id: %i\n", id); return 1; }
primitiveAioSuspend(void) { sqInt exceptionWatch; sqInt fd; sqInt flags; sqInt readWatch; sqInt writeWatch; if ((nilObject()) == (stackValue(3))) { return primitiveFail(); } fd = stackIntegerValue(3); if (fd < 0) { return primitiveFail(); } exceptionWatch = stackObjectValue(2); readWatch = stackObjectValue(1); writeWatch = stackObjectValue(0); flags = 0; if (exceptionWatch == (trueObject())) { flags = flags | (AIO_X); } if (readWatch == (trueObject())) { flags = flags | (AIO_R); } if (writeWatch == (trueObject())) { flags = flags | (AIO_W); } aioSuspend(fd, flags); pop(5); pushInteger(flags); return 0; }
primitiveDropRequestFileName(void) { sqInt dropIndex; char *dropName; sqInt i; sqInt nameLength; sqInt nameOop; char *namePtr; if (!((methodArgumentCount()) == 1)) { return primitiveFail(); } dropIndex = stackIntegerValue(0); /* dropRequestFileName returns name or NULL on error */ dropName = dropRequestFileName(dropIndex); if (dropName == null) { return primitiveFail(); } nameLength = strlen(dropName); nameOop = instantiateClassindexableSize(classString(), nameLength); namePtr = firstIndexableField(nameOop); for (i = 0; i < nameLength; i += 1) { namePtr[i] = (dropName[i]); } pop(2); push(nameOop); return 0; }
primitiveTextureUpload(void) { // B3DAcceleratorPlugin>>#primitiveTextureUpload sqInt bits; void*bitsPtr; sqInt d; sqInt form; sqInt h; sqInt handle; sqInt ppw; sqInt renderer; sqInt result; sqInt w; if (!((methodArgumentCount()) == 3)) { return primitiveFail(); } form = stackValue(0); if (!((isPointers(form)) && ((slotSizeOf(form)) >= 4))) { return primitiveFail(); } bits = fetchPointerofObject(0, form); w = fetchIntegerofObject(1, form); h = fetchIntegerofObject(2, form); d = fetchIntegerofObject(3, form); ppw = 32 / d; if (!(isWords(bits))) { return primitiveFail(); } if (!((slotSizeOf(bits)) == ((((w + ppw) - 1) / ppw) * h))) { return primitiveFail(); } bitsPtr = firstIndexableField(bits); handle = stackIntegerValue(1); renderer = stackIntegerValue(2); if (failed()) { return null; } result = b3dxUploadTexture(renderer, handle, w, h, d, bitsPtr); if (!result) { return primitiveFail(); } return pop(3); }
primitiveEncrypt(void) { sqInt dstLen; sqInt dstOop; char *dstPtr; sqInt handle; sqInt result; sqInt srcLen; sqInt srcOop; char *srcPtr; sqInt start; if (!((methodArgumentCount()) == 5)) { return primitiveFail(); } dstOop = stackObjectValue(0); srcLen = stackIntegerValue(1); start = stackIntegerValue(2); srcOop = stackObjectValue(3); handle = stackIntegerValue(4); if (failed()) { return null; } if (!(((start > 0) && (srcLen >= 0)) && ((isBytes(srcOop)) && ((isBytes(dstOop)) && ((byteSizeOf(srcOop)) >= ((start + srcLen) - 1)))))) { return primitiveFail(); } srcPtr = firstIndexableField(srcOop); dstPtr = firstIndexableField(dstOop); srcPtr = (srcPtr + start) - 1; dstLen = byteSizeOf(dstOop); result = sqEncryptSSL(handle, srcPtr, srcLen, dstPtr, dstLen); if (failed()) { return null; } pop((methodArgumentCount()) + 1); pushInteger(result); return 0; }
primitiveSetIntProperty(void) { // B3DAcceleratorPlugin>>#primitiveSetIntProperty sqInt handle; sqInt prop; sqInt result; sqInt value; if (!((methodArgumentCount()) == 3)) { return primitiveFail(); } value = stackIntegerValue(0); prop = stackIntegerValue(1); handle = stackIntegerValue(2); result = b3dxSetIntProperty(handle, prop, value); if (!result) { return primitiveFail(); } return pop(3); }
primitiveSoundStart(void) { // SoundPlugin>>#primitiveSoundStart sqInt bufFrames; sqInt samplesPerSec; sqInt stereoFlag; bufFrames = stackIntegerValue(2); samplesPerSec = stackIntegerValue(1); stereoFlag = booleanValueOf(stackValue(0)); if (failed()) { return null; } success(snd_Start(bufFrames, samplesPerSec, stereoFlag, 0)); if (failed()) { return null; } pop(3); return null; }
primitiveSoundStartRecording(void) { // SoundPlugin>>#primitiveSoundStartRecording sqInt desiredSamplesPerSec; sqInt semaIndex; sqInt stereoFlag; desiredSamplesPerSec = stackIntegerValue(2); stereoFlag = booleanValueOf(stackValue(1)); semaIndex = stackIntegerValue(0); if (failed()) { return null; } snd_StartRecording(desiredSamplesPerSec, stereoFlag, semaIndex); if (failed()) { return null; } pop(3); return null; }
primitiveGSMDecode(void) { sqInt dst; sqInt dstDelta; sqInt dstIndex; sqInt dstSize; sqInt frameCount; sqInt result; sqInt src; sqInt srcDelta; sqInt srcIndex; sqInt srcSize; sqInt state; dstDelta = 0; srcDelta = 0; dstIndex = stackIntegerValue(0); dst = stackValue(1); srcIndex = stackIntegerValue(2); src = stackValue(3); frameCount = stackIntegerValue(4); state = stackValue(5); success(isWords(dst)); success(isBytes(src)); success(isBytes(state)); if (failed()) { return null; } srcSize = slotSizeOf(src); dstSize = (slotSizeOf(dst)) * 2; gsmDecode(state + BaseHeaderSize, frameCount, src, srcIndex, srcSize, dst, dstIndex, dstSize, &srcDelta, &dstDelta); if (failed()) { return null; } result = makePointwithxValueyValue(srcDelta, dstDelta); if (failed()) { return null; } popthenPush(6, result); return 0; }
primitiveGetIntProperty(void) { sqInt handle; sqInt propID; sqInt value; if (!((methodArgumentCount()) == 2)) { return primitiveFail(); } propID = stackIntegerValue(0); handle = stackIntegerValue(1); if (failed()) { return null; } value = sqGetIntPropertySSL(handle, propID); if (failed()) { return null; } popthenPush((methodArgumentCount()) + 1, signed32BitIntegerFor(value)); return 0; }