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; }
primitiveGetUntrustedUserDirectory(void) { sqInt dirLen; char *dirName; sqInt dirOop; char *dirPtr; sqInt i; dirName = ioGetUntrustedUserDirectory(); if ((dirName == null) || (failed())) { return primitiveFail(); } dirLen = strlen(dirName); dirOop = instantiateClassindexableSize(classString(), dirLen); if (failed()) { return null; } dirPtr = firstIndexableField(dirOop); for (i = 0; i < dirLen; i += 1) { dirPtr[i] = (dirName[i]); } popthenPush(1, dirOop); return 0; }
primitiveErrorAndLog(void) { char *log; sqInt logLen; sqInt logObj; char *logObjData; sqInt resultObj; logLen = 0; log = getlog((&logLen)); resultObj = instantiateClassindexableSize(classArray(), 2); if (resultObj == 0) { primitiveFailFor(PrimErrNoMemory); return null; } storePointerofObjectwithValue(0, resultObj, integerObjectOf(errorAcorn())); if (logLen > 0) { pushRemappableOop(resultObj); logObj = instantiateClassindexableSize(classString(), logLen); if (failed()) { popRemappableOop(); primitiveFailFor(PrimErrNoMemory); return null; } resultObj = popRemappableOop(); logObjData = arrayValueOf(logObj); memcpy(logObjData, log, logLen); storePointerofObjectwithValue(1, resultObj, logObj); } popthenPush(1, resultObj); if (failed()) { return null; } return null; }
primitiveGetMacintoshFileTypeAndCreatorFrom(void) { char *aFileName; char creator[8]; sqInt i; sqInt keyLength; sqInt oop; char *ptr; success(isBytes(stackValue(0))); aFileName = ((char *) (firstIndexableField(stackValue(0)))); if (failed()) { return null; } keyLength = byteSizeOf(((sqInt)(sqIntptr_t)(aFileName) - BaseHeaderSize)); sqInternetGetMacintoshFileTypeAndCreatorFromkeySizeinto(aFileName, keyLength, creator); oop = instantiateClassindexableSize(classString(), 8); ptr = firstIndexableField(oop); for (i = 0; i <= 7; i += 1) { ptr[i] = (creator[i]); } if (failed()) { return null; } popthenPush(2, oop); return null; }
primitiveResetCPU(void) { void *cpu; sqInt cpuAlien; sqInt maybeErr; cpuAlien = stackValue(0); if (failed()) { return null; } if (((cpu = ((longAt(cpuAlien + BaseHeaderSize)) > 0 ? (cpuAlien + BaseHeaderSize) + BytesPerOop : longAt((cpuAlien + BaseHeaderSize) + BytesPerOop)))) == 0) { primitiveFailFor(PrimErrBadReceiver); return null; } maybeErr = resetCPU(cpu); if (maybeErr != 0) { primitiveFailFor(PrimErrInappropriate); return null; } if (failed()) { return null; } popthenPush(1, cpuAlien); return null; }
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; }
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; }
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; }
primitiveSum(void) { // FloatArrayPlugin>>#primitiveSum sqInt i; sqInt length; sqInt rcvr; float *rcvrPtr; double sum; rcvr = stackObjectValue(0); if (failed()) { return null; } success(isWords(rcvr)); if (failed()) { return null; } length = stSizeOf(rcvr); rcvrPtr = ((float *) (firstIndexableField(rcvr))); sum = 0.0; for (i = 0; i <= (length - 1); i += 1) { sum += ((double) (rcvrPtr[i])); } popthenPush(1, floatObjectOf(sum)); }
primitiveLength(void) { // FloatArrayPlugin>>#primitiveLength sqInt i; sqInt length; sqInt rcvr; float *rcvrPtr; double result; rcvr = stackObjectValue(0); if (failed()) { return null; } success(isWords(rcvr)); if (failed()) { return null; } length = stSizeOf(rcvr); success(1); rcvrPtr = ((float *) (firstIndexableField(rcvr))); result = 0.0; for (i = 0; i <= (length - 1); i += 1) { result += (((double) (rcvrPtr[i]))) * (((double) (rcvrPtr[i]))); } result = sqrt(result); popthenPush(1, floatObjectOf(result)); }
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); } }
primitiveGetStringKeyedBy(void) { char *aKey; char aString[1025]; sqInt i; sqInt keyLength; sqInt oop; char *ptr; sqInt size; success(isBytes(stackValue(0))); aKey = ((char *) (firstIndexableField(stackValue(0)))); if (failed()) { return null; } keyLength = byteSizeOf(((sqInt)(sqIntptr_t)(aKey) - BaseHeaderSize)); size = sqInternetConfigurationGetStringKeyedBykeySizeinto(aKey, keyLength, aString); oop = instantiateClassindexableSize(classString(), size); ptr = firstIndexableField(oop); for (i = 0; i < size; i += 1) { ptr[i] = (aString[i]); } if (failed()) { return null; } popthenPush(2, oop); return null; }
primitiveVMOffsetToUTC(void) { sqInt _return_value; _return_value = integerObjectOf((sqLocGetVMOffsetToUTC())); popthenPush(1, _return_value); return null; }
primitiveTimezoneOffset(void) { sqInt _return_value; _return_value = integerObjectOf((sqLocGetTimezoneOffset())); popthenPush(1, _return_value); return null; }
primitiveDisassembleAtInMemory(void) { usqIntptr_t address; void *cpu; sqInt cpuAlien; sqInt instrLenOrErr; sqInt log; sqInt logLen; sqInt logObj; sqInt logObjData; char *memory; sqInt resultObj; logLen = 0; address = (BytesPerOop == 4 ? positive32BitValueOf(stackValue(1)) : positive64BitValueOf(stackValue(1))); success(isWordsOrBytes(stackValue(0))); memory = ((char *) (firstIndexableField(stackValue(0)))); cpuAlien = stackValue(2); if (failed()) { return null; } if (((cpu = ((longAt(cpuAlien + BaseHeaderSize)) > 0 ? (cpuAlien + BaseHeaderSize) + BytesPerOop : longAt((cpuAlien + BaseHeaderSize) + BytesPerOop)))) == 0) { primitiveFailFor(PrimErrBadReceiver); return null; } instrLenOrErr = disassembleForAtInSize(cpu, address, memory, byteSizeOf(((sqInt)(sqIntptr_t)(memory) - BaseHeaderSize))); if (instrLenOrErr < 0) { primitiveFailFor(PrimErrInappropriate); return null; } log = getlog((&logLen)); resultObj = instantiateClassindexableSize(classArray(), 2); if (resultObj == 0) { primitiveFailFor(PrimErrNoMemory); return null; } pushRemappableOop(resultObj); logObj = instantiateClassindexableSize(classString(), logLen); if (failed()) { popRemappableOop(); primitiveFailFor(PrimErrNoMemory); return null; } logObjData = arrayValueOf(logObj); memcpy(logObjData, log, logLen); resultObj = popRemappableOop(); storePointerofObjectwithValue(0, resultObj, integerObjectOf(instrLenOrErr)); storePointerofObjectwithValue(1, resultObj, logObj); if (failed()) { return null; } popthenPush(3, resultObj); return null; }
primitiveGSMNewState(void) { sqInt state; state = instantiateClassindexableSize(classByteArray(), gsmStateBytes()); gsmInitState(state + BaseHeaderSize); popthenPush(1, state); return 0; }
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; }
primitiveDirectoryDelimitor(void) { // FilePlugin>>#primitiveDirectoryDelimitor sqInt ascii; ascii = asciiDirectoryDelimiter(); if ((interpreterProxy->minorVersion()) >= 13) { popthenPush(1, characterObjectOf(ascii)); } else { if ((ascii >= 0) && (ascii <= 0xFF)) { popthenPush(1, fetchPointerofObject(ascii, characterTable())); } else { primitiveFail(); } } }
primPCRECompile(void) { /* begin loadRcvrFromStackAt: */ rcvr = stackObjectValue(0); patternStrPtr = ((char *) (fetchArrayofObject(0, rcvr))); compileFlags = fetchIntegerofObject(1, rcvr); if (failed()) { return null; } pcrePtr = (sqInt) pcre_compile(patternStrPtr, compileFlags, &errorStrBuffer, &errorOffset, NULL); if (pcrePtr) { allocateByteArrayAndSetRcvrPCREPtrFromPCRE(pcrePtr); extraPtr = (sqInt) pcre_study((pcre *)pcrePtr, compileFlags, &errorStrBuffer); allocateByteArrayAndSetRcvrExtraPtrFrom(extraPtr); /* begin rePluginFree: */ numFrees += 1; if ((((void *)pcrePtr)) != null) { free(((void *)pcrePtr)); } if (extraPtr) { /* begin rePluginFree: */ numFrees += 1; if ((((void *)extraPtr)) != null) { free(((void *)extraPtr)); } } if (failed()) { return null; } popthenPush(1, nilObject()); } else { errorStr = allocateStringAndSetRcvrErrorStrFromCStr(errorStrBuffer); /* begin rcvrErrorOffsetFrom: */ storeIntegerofObjectwithValue(5, rcvr, errorOffset); if (failed()) { return null; } popthenPush(1, errorStr); } return 0; }
primitiveCurrencyNotation(void) { sqInt _return_value; _return_value = (((sqLocCurrencyNotation())) ? trueObject() : falseObject()); if (failed()) { return null; } popthenPush(1, _return_value); return null; }
primitiveDaylightSavings(void) { sqInt _return_value; _return_value = (((sqLocDaylightSavings())) ? trueObject() : falseObject()); if (failed()) { return null; } popthenPush(1, _return_value); return null; }
primitiveMeasurementMetric(void) { sqInt _return_value; _return_value = (((sqLocMeasurementMetric())) ? trueObject() : falseObject()); if (failed()) { return null; } popthenPush(1, _return_value); return null; }
primitiveTimezoneOffset(void) { // LocalePlugin>>#primitiveTimezoneOffset sqInt _return_value; _return_value = integerObjectOf((sqLocGetTimezoneOffset())); if (failed()) { return null; } popthenPush(1, _return_value); return null; }
primitiveVMOffsetToUTC(void) { // LocalePlugin>>#primitiveVMOffsetToUTC sqInt _return_value; _return_value = integerObjectOf((sqLocGetVMOffsetToUTC())); if (failed()) { return null; } popthenPush(1, _return_value); return null; }
primitiveDigitGroupingSymbol(void) { sqInt oop; oop = instantiateClassindexableSize(classString(), 1); sqLocGetDigitGroupingSymbolInto(firstIndexableField(oop)); if (failed()) { return null; } popthenPush(1, oop); return null; }
primitiveLanguage(void) { sqInt oop; oop = instantiateClassindexableSize(classString(), 3); sqLocGetLanguageInto(firstIndexableField(oop)); if (failed()) { return null; } popthenPush(1, oop); return null; }
primitiveCountry(void) { // LocalePlugin>>#primitiveCountry sqInt oop; oop = instantiateClassindexableSize(classString(), 3); sqLocGetCountryInto(firstIndexableField(oop)); if (failed()) { return null; } popthenPush(1, oop); return null; }
primitiveDecimalSymbol(void) { // LocalePlugin>>#primitiveDecimalSymbol sqInt oop; oop = instantiateClassindexableSize(classString(), 1); sqLocGetDecimalSymbolInto(firstIndexableField(oop)); if (failed()) { return null; } popthenPush(1, oop); return null; }
primitiveTimeFormat(void) { sqInt length; sqInt oop; length = sqLocTimeFormatSize(); oop = instantiateClassindexableSize(classString(), length); sqLocGetTimeFormatInto(firstIndexableField(oop)); if (failed()) { return null; } popthenPush(1, oop); return null; }