primPCREExec(void) { sqInt extraObj; sqInt length; int *matchSpacePtr; sqInt matchSpaceSize; sqInt result; char *searchBuffer; sqInt searchObject; /* Load Parameters */ searchObject = stackObjectValue(0); searchBuffer = arrayValueOf(searchObject); length = byteSizeOf(searchObject); /* begin loadRcvrFromStackAt: */ rcvr = stackObjectValue(1); 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(2); pushInteger(result); return 0; }
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; }
primPCRENumSubPatterns(void) { sqInt ncap; /* begin loadRcvrFromStackAt: */ rcvr = stackObjectValue(0); pcrePtr = ((sqInt) (fetchArrayofObject(2, rcvr))); pcre_fullinfo((const pcre *)pcrePtr, NULL, PCRE_INFO_CAPTURECOUNT, &ncap); pop(1); pushInteger(ncap); return 0; }
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; }
int primWaveTableSoundmixSampleCountintostartingAtpan(void) { int rcvr; int n; short int *aSoundBuffer; int startIndex; int pan; int lastIndex; int channelIndex; int i; int mySample; int sample; short int *waveTable; int waveTableSize; int count; int amplitude; int increment; int index; rcvr = stackValue(4); n = checkedIntegerValueOf(stackValue(3)); aSoundBuffer = arrayValueOf(stackValue(2)); startIndex = checkedIntegerValueOf(stackValue(1)); pan = checkedIntegerValueOf(stackValue(0)); waveTable = fetchArrayofObject(1, rcvr); waveTableSize = fetchIntegerofObject(2, rcvr); count = fetchIntegerofObject(4, rcvr); amplitude = fetchIntegerofObject(6, rcvr); increment = fetchIntegerofObject(8, rcvr); index = fetchIntegerofObject(9, rcvr); if (!(successFlag)) { return null; } lastIndex = (startIndex + n) - 1; for (i = startIndex; i <= lastIndex; i += 1) { mySample = (amplitude * (waveTable[index - 1])) / 1000; if (pan > 0) { channelIndex = 2 * i; sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * pan) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } if (pan < 1000) { channelIndex = (2 * i) - 1; sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * (1000 - pan)) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } index += increment; if (index > waveTableSize) { index -= waveTableSize; } } count -= n; storeIntegerofObjectwithValue(4, rcvr, count); storeIntegerofObjectwithValue(9, rcvr, index); pop(4); }
int primSampledSoundmixSampleCountintostartingAtpan(void) { int rcvr; int n; short int *aSoundBuffer; int startIndex; int pan; int lastIndex; int i; int channelIndex; int sample; int sampleIndex; int thisSample; short int *samples; int samplesSize; int incrementTimes1000; int count; int indexTimes1000; rcvr = stackValue(4); n = checkedIntegerValueOf(stackValue(3)); aSoundBuffer = arrayValueOf(stackValue(2)); startIndex = checkedIntegerValueOf(stackValue(1)); pan = checkedIntegerValueOf(stackValue(0)); samples = fetchArrayofObject(1, rcvr); samplesSize = fetchIntegerofObject(2, rcvr); incrementTimes1000 = fetchIntegerofObject(3, rcvr); count = fetchIntegerofObject(5, rcvr); indexTimes1000 = fetchIntegerofObject(6, rcvr); if (!(successFlag)) { return null; } lastIndex = (startIndex + n) - 1; i = startIndex; sampleIndex = indexTimes1000 / 1000; while ((sampleIndex <= samplesSize) && (i <= lastIndex)) { thisSample = samples[sampleIndex - 1]; if (pan > 0) { channelIndex = 2 * i; sample = (aSoundBuffer[channelIndex - 1]) + ((thisSample * pan) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } if (pan < 1000) { channelIndex = (2 * i) - 1; sample = (aSoundBuffer[channelIndex - 1]) + ((thisSample * (1000 - pan)) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } indexTimes1000 += incrementTimes1000; sampleIndex = indexTimes1000 / 1000; i += 1; } count -= n; storeIntegerofObjectwithValue(5, rcvr, count); storeIntegerofObjectwithValue(6, rcvr, indexTimes1000); pop(4); }
int primPluckedSoundmixSampleCountintostartingAtpan(void) { int rcvr; int n; short int *aSoundBuffer; int startIndex; int pan; int lastIndex; int channelIndex; int i; int sample; int mySample; int thisIndex; int nextIndex; int count; short int *ring; int ringSize; int ringIndx; rcvr = stackValue(4); n = checkedIntegerValueOf(stackValue(3)); aSoundBuffer = arrayValueOf(stackValue(2)); startIndex = checkedIntegerValueOf(stackValue(1)); pan = checkedIntegerValueOf(stackValue(0)); count = fetchIntegerofObject(2, rcvr); ring = fetchArrayofObject(4, rcvr); ringSize = fetchIntegerofObject(5, rcvr); ringIndx = fetchIntegerofObject(6, rcvr); if (!(successFlag)) { return null; } lastIndex = (startIndex + n) - 1; thisIndex = ringIndx; for (i = startIndex; i <= lastIndex; i += 1) { nextIndex = (thisIndex % ringSize) + 1; mySample = ((ring[thisIndex - 1]) + (ring[nextIndex - 1])) / 2; ring[thisIndex - 1] = mySample; thisIndex = nextIndex; if (pan > 0) { channelIndex = 2 * i; sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * pan) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } if (pan < 1000) { channelIndex = (2 * i) - 1; sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * (1000 - pan)) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } } ringIndx = nextIndex; count -= n; storeIntegerofObjectwithValue(2, rcvr, count); storeIntegerofObjectwithValue(6, rcvr, ringIndx); pop(4); }
/* RePlugin>>#rcvrPCREBufferPtr */ static sqInt rcvrPCREBufferPtr(void) { return ((sqInt) (fetchArrayofObject(2, rcvr))); }
/* RePlugin>>#rcvrPatternStrPtr */ static char * rcvrPatternStrPtr(void) { return ((char *) (fetchArrayofObject(0, rcvr))); }
/* RePlugin>>#rcvrMatchSpacePtr */ static int * rcvrMatchSpacePtr(void) { return ((int *) (fetchArrayofObject(7, rcvr))); }