primitiveFileCopyNamedTo(void)
{
	// FileCopyPlugin>>#primitiveFileCopyNamedTo
	char *dstName;
	sqInt dstSz;
	sqInt ok;
	char *srcName;
	sqInt srcSz;

	success(isBytes(stackValue(1)));
	srcName = ((char *) (firstIndexableField(stackValue(1))));
	success(isBytes(stackValue(0)));
	dstName = ((char *) (firstIndexableField(stackValue(0))));
	if (failed()) {
		return null;
	}
	srcSz = slotSizeOf(((sqInt)(long)(srcName) - 4));
	dstSz = slotSizeOf(((sqInt)(long)(dstName) - 4));
	ok = sqCopyFilesizetosize(srcName, srcSz, dstName, dstSz);
	if (!ok) {
primitiveFail();
	}
	if (failed()) {
		return null;
	}
	pop(2);
	return null;
}
static sqInt
stackLightArrayValue(sqInt stackIndex)
{
	// B3DAcceleratorPlugin>>#stackLightArrayValue:
    sqInt array;
    sqInt arraySize;
    sqInt i;
    sqInt oop;

	array = stackObjectValue(stackIndex);
	if (array == null) {
return null;
	}
	if (array == (nilObject())) {
		return null;
	}
	if (!((fetchClassOf(array)) == (classArray()))) {
		return primitiveFail();
	}
	arraySize = slotSizeOf(array);
	for (i = 0; i <= (arraySize - 1); i += 1) {
		oop = fetchPointerofObject(i, array);
		if (isIntegerObject(oop)) {
			return primitiveFail();
		}
		if (!((isWords(oop))
			 && ((slotSizeOf(oop)) == 32))) {
			return primitiveFail();
		}
	}
	return array;
}
static sqInt
loadClientStateverticescolorsnormalstexCoords(sqInt handle, sqInt vertices, sqInt colors, sqInt normals, sqInt texCoords)
{
	// B3DAcceleratorPlugin>>#loadClientState:vertices:colors:normals:texCoords:
    void *colorPtr;
    void *normalPtr;
    sqInt ok;
    sqInt sz;
    void *txPtr;
    void *vertexPtr;
    sqInt vtxSize;


	/* Verify vertex data */

colorPtr = (normalPtr = (txPtr = (vertexPtr = null)));
	if (!(isWords(vertices))) {
		return primitiveFail();
	}

	/* Verify assumptions of color, normal, texCoords data */

vtxSize = (slotSizeOf(vertices)) / 3;
	if (!((colors == (nilObject()))
		 || ((isWords(colors))
		 && ((slotSizeOf(colors)) == (vtxSize * 4))))) {
		return primitiveFail();
	}
	if (!((normals == (nilObject()))
		 || ((isWords(normals))
		 && ((slotSizeOf(normals)) == (vtxSize * 3))))) {
		return primitiveFail();
	}
	if (!((texCoords == (nilObject()))
		 || (isWords(texCoords)))) {
		return primitiveFail();
	}
	if (!(colors == (nilObject()))) {
		colorPtr = firstIndexableField(colors);
	}
	if (!(normals == (nilObject()))) {
		normalPtr = firstIndexableField(normals);
	}
	if (!(texCoords == (nilObject()))) {
		sz = (slotSizeOf(texCoords)) / vtxSize;
		txPtr = firstIndexableField(texCoords);
	}
	vertexPtr = firstIndexableField(vertices);
	if (failed()) {
		return null;
	}
	ok = b3dLoadClientState(handle, vertexPtr, 3, colorPtr, 4, normalPtr, 3, txPtr, sz);
	if (!ok) {
return primitiveFail();
	}
}
Ejemplo n.º 4
0
primitiveIsPureTranslation(void)
{
    float *matrix;
    sqInt matrix1;

	/* begin loadArgumentMatrix: */
	matrix1 = stackObjectValue(0);
	if (failed()) {
		matrix = null;
		goto l1;
	}
	if (!((isWords(matrix1))
		 && ((slotSizeOf(matrix1)) == 6))) {
		primitiveFail();
		matrix = null;
		goto l1;
	}
	matrix = ((float *) (firstIndexableField(matrix1)));
	l1:	/* end loadArgumentMatrix: */;
	if (failed()) {
		return null;
	}
	pop(1);
	pushBool(((((matrix[0]) == (((float) 1.0))) && ((matrix[1]) == (((float) 0.0)))) && ((matrix[3]) == (((float) 0.0)))) && ((matrix[4]) == (((float) 1.0))));
	return 0;
}
Ejemplo n.º 5
0
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;
}
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);
	}
}
static void*
stackPrimitiveIndexArrayofSizevalidateforVertexSize(sqInt stackIndex, sqInt nItems, sqInt aBool, sqInt maxIndex)
{
	// B3DAcceleratorPlugin>>#stackPrimitiveIndexArray:ofSize:validate:forVertexSize:
    sqInt i;
    int *idxPtr;
    sqInt index;
    sqInt oop;
    sqInt oopSize;

	oop = stackObjectValue(stackIndex);
	if (oop == null) {
return null;
	}
	if (!(isWords(oop))) {
		return null;
	}
	oopSize = slotSizeOf(oop);
	if (oopSize < nItems) {
return null;
	}
	idxPtr = ((int *) (firstIndexableField(oop)));
	if (aBool) {
for (i = 0; i <= (nItems - 1); i += 1) {
			index = idxPtr[i];
			if ((index < 0)
			 || (index > maxIndex)) {
return null;
			}
		}
	}
	return idxPtr;
}
Ejemplo n.º 8
0
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;
}
Ejemplo n.º 9
0
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;
}
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;
}
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);
}
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;
}
Ejemplo n.º 13
0
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;
}
static AsyncFile *
asyncFileValueOf(sqInt oop)
{
	// AsynchFilePlugin>>#asyncFileValueOf:
	success((!(isIntegerObject(oop)))
	 && ((isBytes(oop))
	 && ((slotSizeOf(oop)) == (sizeof(AsyncFile)))));
	if (failed()) {
		return null;
	}
	return (AsyncFile *) (oop + 4);
}
Ejemplo n.º 15
0
	/* Matrix2x3Plugin>>#loadArgumentMatrix: */
static float *
loadArgumentMatrix(sqInt matrix)
{
	if (failed()) {
		return null;
	}
	if (!((isWords(matrix))
		 && ((slotSizeOf(matrix)) == 6))) {
		primitiveFail();
		return null;
	}
	return ((float *) (firstIndexableField(matrix)));
}
static sqInt
checkBoundsRangefacescount(sqInt vertices, unsigned int *facePtr, sqInt faceCount)
{
	// B3DAcceleratorPlugin>>#checkBoundsRange:faces:count:
    sqInt i;
    sqInt vtxSize;

	vtxSize = (slotSizeOf(vertices)) / 3;
	for (i = 0; i <= (faceCount - 1); i += 1) {
		if ((facePtr[i]) > vtxSize) {
			return primitiveFail();
		}
	}
}
Ejemplo n.º 17
0
	/* FFTPlugin>>#loadFFTFrom: */
static sqInt
loadFFTFrom(sqInt fftOop)
{
    sqInt oop;

	success((slotSizeOf(fftOop)) >= 6);
	if (failed()) {
		return 0;
	}
	nu = fetchIntegerofObject(0, fftOop);
	fftSize = fetchIntegerofObject(1, fftOop);
	oop = fetchPointerofObject(2, fftOop);
	sinTableSize = stSizeOf(oop);
	/* begin checkedFloatPtrOf: */
	success(isWords(oop));
	if (failed()) {
		sinTable = 0;
		goto l1;
	}
	sinTable = ((float *) (firstIndexableField(oop)));
l1:	/* end checkedFloatPtrOf: */;
	oop = fetchPointerofObject(3, fftOop);
	permTableSize = stSizeOf(oop);
	/* begin checkedWordPtrOf: */
	success(isWords(oop));
	permTable = ((unsigned int *) (firstIndexableField(oop)));
	oop = fetchPointerofObject(4, fftOop);
	realDataSize = stSizeOf(oop);
	/* begin checkedFloatPtrOf: */
	success(isWords(oop));
	if (failed()) {
		realData = 0;
		goto l3;
	}
	realData = ((float *) (firstIndexableField(oop)));
l3:	/* end checkedFloatPtrOf: */;
	oop = fetchPointerofObject(5, fftOop);
	imagDataSize = stSizeOf(oop);
	/* begin checkedFloatPtrOf: */
	success(isWords(oop));
	if (failed()) {
		imagData = 0;
		goto l4;
	}
	imagData = ((float *) (firstIndexableField(oop)));
l4:	/* end checkedFloatPtrOf: */;
	success((((((1L << nu) == fftSize) && (((fftSize / 4) + 1) == sinTableSize)) && (fftSize == realDataSize)) && (fftSize == imagDataSize)) && (realDataSize == imagDataSize));
	return (failed()) == 0;
}
Ejemplo n.º 18
0
primitiveFileRead(void)
{
	// FilePlugin>>#primitiveFileRead
    sqInt array;
    sqInt bytesRead;
    size_t count;
    size_t elementSize;
    SQFile *file;
    sqInt objectPointer;
    sqInt retryCount;
    size_t startIndex;

	retryCount = 0;
	count = positive32BitValueOf(stackValue(0));
	startIndex = positive32BitValueOf(stackValue(1));
	while (1) {
array = stackValue(2);
		/* begin fileValueOf: */
		objectPointer = stackValue(3);
		if (!((isBytes(objectPointer))
			 && ((byteSizeOf(objectPointer)) == (sizeof(SQFile))))) {
			primitiveFail();
			file = null;
			goto l1;
		}
		file = firstIndexableField(objectPointer);
	l1:	/* end fileValueOf: */;
		if ((failed())
		 || (!(isWordsOrBytes(array)))) {
			return primitiveFailFor(PrimErrBadArgument);
		}
		elementSize = (isWords(array)
			? 4
			: 1);
		if (!((startIndex >= 1)
			 && (((startIndex + count) - 1) <= (slotSizeOf(array))))) {
			return primitiveFailFor(PrimErrBadIndex);
		}
		bytesRead = sqFileReadIntoAt(file, count * elementSize, ((char *) (firstIndexableField(array))), (startIndex - 1) * elementSize);
		if (!(((primitiveFailureCode()) == PrimErrObjectMayMove)
		 && (((retryCount += 1)) <= 2))) break;
		tenuringIncrementalGC();
		primitiveFailFor(PrimNoErr);
	}
	if (!(failed())) {
		popthenPush(5, integerObjectOf(bytesRead / elementSize));
	}
}
static void*
stackPrimitiveVertex(sqInt index)
{
	// B3DAcceleratorPlugin>>#stackPrimitiveVertex:
    sqInt oop;

	oop = stackObjectValue(index);
	if (oop == null) {
return null;
	}
	if ((isWords(oop))
	 && ((slotSizeOf(oop)) == 16)) {
		return firstIndexableField(oop);
	}
	return null;
}
static sqInt
checkVertexData(sqInt vertices)
{
	// B3DAcceleratorPlugin>>#checkVertexData:
    float f;
    sqInt i;
    float *vtxPtr;
    sqInt vtxSize;

	vtxSize = slotSizeOf(vertices);
	vtxPtr = firstIndexableField(vertices);
	for (i = 0; i <= (vtxSize - 1); i += 1) {
		f = vtxPtr[i];
		if (isnan(f - f)) {
			return primitiveFail();
		}
	}
}
Ejemplo n.º 21
0
primitiveTransformPoint(void)
{
    float *matrix;
    sqInt matrix1;

	loadArgumentPoint(stackObjectValue(0));
	/* begin loadArgumentMatrix: */
	matrix1 = stackObjectValue(1);
	if (failed()) {
		matrix = null;
		goto l1;
	}
	if (!((isWords(matrix1))
		 && ((slotSizeOf(matrix1)) == 6))) {
		primitiveFail();
		matrix = null;
		goto l1;
	}
	matrix = ((float *) (firstIndexableField(matrix1)));
	l1:	/* end loadArgumentMatrix: */;
	if (failed()) {
		return null;
	}
	/* begin matrix2x3TransformPoint: */
	m23ResultX = ((m23ArgX * (matrix[0])) + (m23ArgY * (matrix[1]))) + (matrix[2]);
	m23ResultY = ((m23ArgX * (matrix[3])) + (m23ArgY * (matrix[4]))) + (matrix[5]);
	/* begin roundAndStoreResultPoint: */
	m23ResultX += 0.5;
	m23ResultY += 0.5;
	if (!((m23ResultX >= (((double) (MinSmallInteger) )))
		 && (m23ResultX <= (((double) (MaxSmallInteger) ))))) {
		primitiveFail();
		goto l2;
	}
	if (!((m23ResultY >= (((double) (MinSmallInteger) )))
		 && (m23ResultY <= (((double) (MaxSmallInteger) ))))) {
		primitiveFail();
		goto l2;
	}
	popthenPush(2, makePointwithxValueyValue(((sqInt)m23ResultX), ((sqInt)m23ResultY)));
	l2:	/* end roundAndStoreResultPoint: */;
	return 0;
}
static void *
stackMaterialValue(sqInt stackIndex)
{
	// B3DAcceleratorPlugin>>#stackMaterialValue:
    sqInt oop;

	oop = stackObjectValue(stackIndex);
	if (oop == null) {
return null;
	}
	if (oop == (nilObject())) {
		return null;
	}
	if ((isWords(oop))
	 && ((slotSizeOf(oop)) == 17)) {
		return firstIndexableField(oop);
	}
	return null;
}
static void*
stackPrimitiveVertexArrayofSize(sqInt index, sqInt nItems)
{
	// B3DAcceleratorPlugin>>#stackPrimitiveVertexArray:ofSize:
    sqInt oop;
    sqInt oopSize;

	oop = stackObjectValue(index);
	if (oop == null) {
return null;
	}
	if (isWords(oop)) {
		oopSize = slotSizeOf(oop);
		if (((oopSize >= nItems) * 16)
		 && ((oopSize % 16) == 0)) {
			return firstIndexableField(oop);
		}
	}
	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;
}
primitiveSerialPortOpenByName(void)
{
	// SerialPlugin>>#primitiveSerialPortOpenByName
	sqInt baudRate;
	sqInt dataBits;
	sqInt inFlowControl;
	sqInt outFlowControl;
	sqInt parityType;
	char *port;
	char *portName;
	sqInt portNameSize;
	sqInt stopBitsType;
	sqInt xOffChar;
	sqInt xOnChar;

	success(isBytes(stackValue(8)));
	portName = ((char *) (firstIndexableField(stackValue(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;
	}
	portNameSize = slotSizeOf(((int) portName) - 4);
	port = calloc(portNameSize+1, sizeof(char));
	memcpy(port, portName, portNameSize);
	serialPortOpenByName(
			port, baudRate, stopBitsType, parityType, dataBits,
			inFlowControl, outFlowControl, xOnChar, xOffChar);
	free(port);
	if (failed()) {
		return null;
	}
	pop(9);
	return null;
}
Ejemplo n.º 26
0
primitiveAt(void)
{
    float *floatPtr;
    double floatValue;
    sqInt index;
    sqInt rcvr;

	index = stackIntegerValue(0);
	rcvr = stackValue(1);
	if (!((!(failed()))
		 && ((isWords(rcvr))
		 && ((index > 0)
		 && (index <= (slotSizeOf(rcvr))))))) {
		return primitiveFail();
	}
	floatPtr = firstIndexableField(rcvr);
	floatValue = ((double) (floatPtr[index - 1]) );
	pop(2);
	pushFloat(floatValue);
	return 0;
}
Ejemplo n.º 27
0
primitiveFileWrite(void)
{
	// FilePlugin>>#primitiveFileWrite
    sqInt array;
    sqInt bytesWritten;
    size_t count;
    size_t elementSize;
    SQFile *file;
    sqInt objectPointer;
    size_t startIndex;

	count = positive32BitValueOf(stackValue(0));
	startIndex = positive32BitValueOf(stackValue(1));
	array = stackValue(2);
	/* begin fileValueOf: */
	objectPointer = stackValue(3);
	if (!((isBytes(objectPointer))
		 && ((byteSizeOf(objectPointer)) == (sizeof(SQFile))))) {
		primitiveFail();
		file = null;
		goto l1;
	}
	file = firstIndexableField(objectPointer);
l1:	/* end fileValueOf: */;
	if ((failed())
	 || (!(isWordsOrBytes(array)))) {
		return primitiveFailFor(PrimErrBadArgument);
	}
	elementSize = (isWords(array)
		? 4
		: 1);
	if (!((startIndex >= 1)
		 && (((startIndex + count) - 1) <= (slotSizeOf(array))))) {
		return primitiveFailFor(PrimErrBadIndex);
	}
	bytesWritten = sqFileWriteFromAt(file, count * elementSize, ((char *) (firstIndexableField(array))), (startIndex - 1) * elementSize);
	if (!(failed())) {
		popthenPush(5, integerObjectOf(bytesWritten / elementSize));
	}
}
Ejemplo n.º 28
0
primitiveSerialPortWriteByName(void)
{
	char *array;
	char * arrayPtr;
	sqInt bytesWritten;
	sqInt count;
	char *port;
	char *portName;
	sqInt portNameSize;
	sqInt startIndex;
	sqInt _return_value;

	bytesWritten = 0;
	success(isBytes(stackValue(3)));
	portName = ((char *) (firstIndexableField(stackValue(3))));
	success(isBytes(stackValue(2)));
	array = ((char *) (firstIndexableField(stackValue(2))));
	startIndex = stackIntegerValue(1);
	count = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	portNameSize = slotSizeOf(((sqInt)((portName) - BaseHeaderSize)));
	port = calloc(portNameSize+1, sizeof(char));
	memcpy(port, portName, portNameSize);
	success((startIndex >= 1)
	 && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize)))));
	if (!(failed())) {
		arrayPtr = (array + startIndex) - 1;
		bytesWritten = serialPortWriteFromByName(port, count, arrayPtr);
	}
	free(port);
	if (failed()) {
		return null;
	}
	_return_value = integerObjectOf(bytesWritten);
	popthenPush(5, _return_value);
	return null;
}
primitiveTextureGetColorMasks(void)
{
	// B3DAcceleratorPlugin>>#primitiveTextureGetColorMasks
    sqInt array;
    sqInt arrayOop;
    sqInt handle;
    sqInt i;
    int masks[4];
    sqInt renderer;
    sqInt result;

	if (!((methodArgumentCount()) == 3)) {
		return primitiveFail();
	}
	array = stackObjectValue(0);
	handle = stackIntegerValue(1);
	renderer = stackIntegerValue(2);
	if (failed()) {
		return null;
	}
	if (!((fetchClassOf(array)) == (classArray()))) {
		return primitiveFail();
	}
	if (!((slotSizeOf(array)) == 4)) {
		return primitiveFail();
	}
	result = b3dxTextureColorMasks(renderer, handle, masks);
	if (!result) {
return primitiveFail();
	}
	arrayOop = array;
	for (i = 0; i <= 3; i += 1) {
pushRemappableOop(arrayOop);
		result = positive32BitIntegerFor(masks[i]);
		arrayOop = popRemappableOop();
		storePointerofObjectwithValue(i, arrayOop, result);
	}
	return pop(3);
}
primitiveSetLights(void)
{
	// B3DAcceleratorPlugin>>#primitiveSetLights
    sqInt handle;
    sqInt i;
    void*light;
    sqInt lightArray;
    sqInt lightCount;
    sqInt lightOop;

	if (!((methodArgumentCount()) == 2)) {
		return primitiveFail();
	}
	lightArray = stackLightArrayValue(0);
	handle = stackIntegerValue(1);
	if (failed()) {
		return null;
	}
	if (!(b3dxDisableLights(handle))) {
		return primitiveFail();
	}
	if (lightArray == null) {
return null;
	}

	/* For each enabled light source */

lightCount = slotSizeOf(lightArray);
	for (i = 0; i <= (lightCount - 1); i += 1) {
		/* begin fetchLightSource:ofObject: */
lightOop = fetchPointerofObject(i, lightArray);
		light = firstIndexableField(lightOop);
		if (!(b3dxLoadLight(handle, i, light))) {
			return primitiveFail();
		}
	}
	return pop(2);
}