Beispiel #1
0
IoSeq *IoAVCode_frameSeqForAVFrame_(IoAVCodec *self, AVFrame *avframe, int srcPixelFormat, int width, int height)
{
	AVPicture *rgbPicture = IoAVCode_allocDstPictureIfNeeded(self, PIX_FMT_RGB24, width, height);
	int result;
        
        struct SwsContext *img_convert_ctx;
        img_convert_ctx = sws_getContext(width, height, srcPixelFormat,
                                         width, height, PIX_FMT_RGB24,
                                         SWS_BICUBIC, NULL, NULL, NULL);
        
	result = sws_scale(img_convert_ctx, 
                           avframe->data,    avframe->linesize, 0, height, 
                           rgbPicture->data, rgbPicture->linesize);

        sws_freeContext(img_convert_ctx);

        if (result)
	{
		printf("AVCodec: sws_scale error?\n");
	}

	UArray *data = UArray_newWithData_type_encoding_size_copy_(rgbPicture->data[0], CTYPE_uint8_t, CENCODING_NUMBER, width * height * 3, 1);

	return IoSeq_newWithUArray_copy_(IOSTATE, data, 0);
}
Beispiel #2
0
Datei: IoFile.c Projekt: achoy/io
IO_METHOD(IoFile, contents)
{
	/*doc File contents
	Returns contents of the file as a mutable Sequence of bytes.
	*/

	UArray *ba = UArray_new();
	long result = -1;

	if (DATA(self)->stream == stdin)
	{
		result = UArray_readFromCStream_(ba, DATA(self)->stream);
	}
	else
	{
		result = UArray_readFromFilePath_(ba, IoSeq_rawUArray(DATA(self)->path));
	}

	if (result != -1)
	{
		return IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
	}
	else
	{
		UArray_free(ba);
		IoState_error_(IOSTATE, m, "unable to read file '%s'", UTF8CSTRING(DATA(self)->path));
	}

	return IONIL(self);
}
Beispiel #3
0
IoObject *IoImage_histogram(IoImage *self, IoObject *locals, IoMessage *m)
{
	/*doc Image histogram
	Returns array with histogram values interleaved by channels.
	*/
	return IoSeq_newWithUArray_copy_(IOSTATE, Image_histogram(DATA(self)->image), 0);
}
Beispiel #4
0
IO_METHOD(IoSeq, inclusiveSlice)
{
	/*doc Sequence inclusiveSlice(inclusiveStartIndex, inclusiveEndIndex)
	Returns a new string containing the subset of the
	receiver from the inclusiveStartIndex to the inclusiveEndIndex. The inclusiveEndIndex argument
	is optional. If not given, it is assumed to be the end of the string. 
	*/

	long fromIndex = IoMessage_locals_longArgAt_(m, locals, 0);
	long last = UArray_size(DATA(self));
	UArray *ba;

	if (IoMessage_argCount(m) > 1)
	{
		last = IoMessage_locals_longArgAt_(m, locals, 1);
	}

	if (last == -1)
	{
		last = UArray_size(DATA(self));
	}
	else
	{
		last = last + 1;
	}
	
	ba = UArray_slice(DATA(self), fromIndex, last);

	if (ISSYMBOL(self))
	{
		return IoState_symbolWithUArray_copy_(IOSTATE, ba, 0);
	}

	return IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
}
Beispiel #5
0
IoObject *IoODEMass_parameters(IoODEMass *self, IoObject *locals, IoMessage *m)
{
	// vector(theMass, cgx, cgy, cgz, I11, I22, I33, I12, I13, I23)

	UArray *u = UArray_new();
	int i, j = 0;

	UArray_setItemType_(u, CTYPE_float32_t);
	UArray_setSize_(u, 10);

	UArray_at_putDouble_(u, j++, DATA(self)->mass);

	for(i=0; i < 3; i++)
	{
		UArray_at_putDouble_(u, j++, DATA(self)->c[i]);
	}

	//              0    1    2   3   4    5    6   7   8    9   10  11
	// I == vector(I11, I12, I13, _, I12, I22, I23, _, I13, I23, I33, _)
	UArray_at_putDouble_(u, j++, DATA(self)->I[0 ]); // I11
	UArray_at_putDouble_(u, j++, DATA(self)->I[5 ]); // I22
	UArray_at_putDouble_(u, j++, DATA(self)->I[10]); // I33
	UArray_at_putDouble_(u, j++, DATA(self)->I[1 ]); // I12
	UArray_at_putDouble_(u, j++, DATA(self)->I[2 ]); // I13
	UArray_at_putDouble_(u, j++, DATA(self)->I[6 ]); // I23

	return IoSeq_newWithUArray_copy_(IOSTATE, u, 1);
}
Beispiel #6
0
void IoAVCodec_createContextIfNeeded(IoAVCodec *self)
{
	if(!DATA(self)->packet)
	{
		DATA(self)->packet = calloc(1, sizeof(AVPacket));
	}

	// video

	// frames
	if (!DATA(self)->frames)
	{
		DATA(self)->frames = IoList_new(IOSTATE);
		IoObject_setSlot_to_(self, IOSYMBOL("frames"), DATA(self)->frames);
	}

	// videoSize
	{
		UArray *sizeUArray = UArray_newWithData_type_encoding_size_copy_("", CTYPE_float32_t, CENCODING_NUMBER, 2, 1);
		IoSeq *sizeSeq = IoSeq_newWithUArray_copy_(IOSTATE, sizeUArray, 0);
		IoObject_setSlot_to_(self, IOSYMBOL("videoSize"), sizeSeq);
	}

	if (!DATA(self)->decodedFrame)
	{
		DATA(self)->decodedFrame = avcodec_alloc_frame();
	}

	// audio

	if(!DATA(self)->audioOutBuffer)
	{
		DATA(self)->audioOutBuffer = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
	}
}
Beispiel #7
0
IoObject *IoTokyoCabinetPrefixCursor_key(IoObject *self, IoObject *locals, IoMessage *m)
{
	/*doc TokyoCabinetPrefixCursor key
	Returns current cursor key or nil.
	*/
	
	int size;
	char *ks;
	
	IoSeq *prefix = IoObject_getSlot_(self, IOSYMBOL("prefix"));
	IOASSERT(ISSEQ(prefix), "prefix must be a sequence");
	IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
	ks = tcbdbcurkey(TokyoCabinetPrefixCursor(self), &size);

	if (ks)
	{
		UArray *k = UArray_newWithData_type_size_copy_(ks, CTYPE_uint8_t, size, 1);
	
		if (UArray_beginsWith_(k, IoSeq_rawUArray(prefix)))
		{
			//printf("prefix '%s'\n", UArray_bytes(IoSeq_rawUArray(prefix)));
			//printf("before clip '%s'\n", UArray_bytes(k));
			UArray_clipBeforeEndOf_(k, IoSeq_rawUArray(prefix));
			UArray_removeFirst(k); // remove separator
			//printf("after clip  '%s'\n", UArray_bytes(k));
			return IoSeq_newWithUArray_copy_(IOSTATE, k, 0);
		}

		UArray_free(k);
	}

	return IONIL(self);
}
Beispiel #8
0
Datei: IoDate.c Projekt: bomma/io
IoSeq *IoDate_asSerialization(IoDate *self, IoObject *locals, IoMessage *m)
{
	/*doc Date asSerialization
	Returns a serialization (sequence) of the date that allows for perfect reconstruction of the timestamp.
	*/

	return IoSeq_newWithUArray_copy_(IOSTATE, (UArray *) Date_asSerialization(DATA(self)), 0);
}
Beispiel #9
0
IoObject *IoSeq_asUTF8(IoSeq *self, IoObject *locals, IoMessage *m)
{
	/*doc Sequence asUTF8
	Returns a new copy of the receiver converted to utf8 encoding. 
	*/

	return IoSeq_newWithUArray_copy_(IOSTATE, UArray_asUTF8(DATA(self)), 0);
}
Beispiel #10
0
IoObject *IoSeq_asUCS4(IoSeq *self, IoObject *locals, IoMessage *m)
{
	/*doc Sequence asUCS4
	Returns a new copy of the receiver converted to UCS4 (fixed character width UTF32) encoding. 
	*/

	return IoSeq_newWithUArray_copy_(IOSTATE, UArray_asUCS4(DATA(self)), 0);
}
Beispiel #11
0
IO_METHOD(IoSeq, asUCS4)
{
	/*doc Sequence asUCS4
	Returns a new copy of the receiver converted to UCS4 (fixed character width UTF32) encoding. 
	*/

	return IoSeq_newWithUArray_copy_(IOSTATE, UArray_asUCS4(DATA(self)), 0);
}
Beispiel #12
0
IO_METHOD(IoSeq, asUTF8)
{
	/*doc Sequence asUTF8
	Returns a new copy of the receiver converted to utf8 encoding. 
	*/

	return IoSeq_newWithUArray_copy_(IOSTATE, UArray_asUTF8(DATA(self)), 0);
}
Beispiel #13
0
IoObject *IoLinker_hexSeqToBytes(IoLinker *self, IoObject *locals, IoMessage *m)
{
/*doc Linker hexSeqToBytes(aSeq)
Returns a Sequence containing a binary representation of the hex data in aSeq. 
*/
	IoSeq *buffer = IoMessage_locals_seqArgAt_(m, locals, 0);
	UArray *ba = IoSeq_rawUArray(buffer);
	return IoSeq_newWithUArray_copy_(IOSTATE, UArray_fromHexStringUArray(ba), 0);
}
Beispiel #14
0
Datei: IoSHA1.c Projekt: ADTSH/io
IoObject *IoSHA1_sha1(IoSHA1 *self, IoObject *locals, IoMessage *m)
{
	/*doc SHA1 sha1
	Completes the SHA1 calculation and returns the hash as a Buffer.
	Once this method is called, append() should not be called again on the receiver or it will raise an exception.
	*/
	
	return IoSeq_newWithUArray_copy_(IOSTATE, IoSHA1_sha1UArray(self), 0);
}
Beispiel #15
0
IoObject *IoLinker_bytesToHexSeq(IoLinker *self, IoObject *locals, IoMessage *m)
{
/*doc Linker bytesToHexSeq(aSeq)
Returns a Sequence containing a hex representation of aSeq. 
*/
	
	IoSeq *buffer = IoMessage_locals_seqArgAt_(m, locals, 0);
	UArray *ba = IoSeq_rawUArray(buffer);
	return IoSeq_newWithUArray_copy_(IOSTATE, UArray_asNewHexStringUArray(ba), 0);
}
Beispiel #16
0
IO_METHOD(IoSeq, between)
{
	/*doc Sequence between(aSequence, anotherSequence)
	Returns a new Sequence containing the bytes between the
	occurance of aSequence and anotherSequence in the receiver.
	*/

	long start = 0;
	long end = 0;
	IoSeq *fromSeq, *toSeq;

	fromSeq = (IoSeq *)IoMessage_locals_valueArgAt_(m, locals, 0);

	if (ISSEQ(fromSeq))
	{
		start = UArray_find_from_(DATA(self), DATA(fromSeq), 0) + IoSeq_rawSize(fromSeq);

		if (start == -1)
		{
			start = 0;
		}
	}
	else if (ISNIL(fromSeq))
	{
		start = 0;
	}
	else
	{
		IoState_error_(IOSTATE, m, "Nil or Sequence argument required for arg 0, not a %s",
					IoObject_name((IoObject *)fromSeq));
	}

	toSeq = (IoSeq *)IoMessage_locals_valueArgAt_(m, locals, 1);

	if (ISSEQ(toSeq))
	{
		end = UArray_find_from_(DATA(self), DATA(toSeq), start);
		if (end == -1) start = UArray_size(DATA(self));
	}
	else if (ISNIL(toSeq))
	{
		end = UArray_size(DATA(self));
	}
	else
	{
		IoState_error_(IOSTATE, m, "Nil or Sequence argument required for arg 1, not a %s",
					IoObject_name((IoObject *)toSeq));
	}

	{
		UArray *ba = UArray_slice(DATA(self), start, end);
		IoSeq *result = IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
		return result;
	}
}
Beispiel #17
0
void IoSandbox_printCallback(void *voidSelf, const UArray *ba)
{
	IoSandbox *self = voidSelf;

	IoState *state = IOSTATE;
	IoSeq *buf = IoSeq_newWithUArray_copy_(IOSTATE, (UArray *)ba, 1);
	IoMessage *m = IoMessage_newWithName_(state, IOSYMBOL("printCallback"));
	IoMessage *arg = IoMessage_newWithName_returnsValue_(state, IOSYMBOL("buffer"), buf);
	IoMessage_addArg_(m, arg);
	IoMessage_locals_performOn_(m, state->lobby, self);
}
Beispiel #18
0
IoObject *IoTagDB_allUniqueTagIds(IoTagDB *self, IoObject *locals, IoMessage *m)
{
	/*doc TagDB allUniqueTagIds
	Returns a list of all unique tag ids.
	*/
	
	Uint64Array *tagIds = TagDB_allUniqueTags(DATA(self)); 
	UArray *ua = UArray_newWithData_type_size_copy_(Uint64Array_data(tagIds), CTYPE_uint64_t, Uint64Array_size(tagIds), 1);
	
	Uint64Array_free(tagIds);	
	return IoSeq_newWithUArray_copy_(IOSTATE, ua, 0);
}
Beispiel #19
0
IO_METHOD(IoSeq, asFixedSizeType)
{
	/*doc Sequence asFixedSizeType
	Returns a new sequence with the receiver encoded in the 
	minimal fixed width text encoding that it's characters can fit 
	into (either, ascii, utf8, utf16 or utf32). 
	*/
	
	UArray *out = UArray_new();
	UArray_copy_(out, DATA(self));
	UArray_convertToFixedSizeType(out);	
	return IoSeq_newWithUArray_copy_(IOSTATE, out, 0);
}
Beispiel #20
0
IoObject *IoTagDB_keysForTags(IoTagDB *self, IoObject *locals, IoMessage *m)
{
	/*doc TagDB keysForTags(aTagNameList)
	Returns list of keys whose tags contain all of the tags in aTagNameList.
	*/
	TagDB *tdb = DATA(self);
	IoList *tagNames = IoMessage_locals_listArgAt_(m, locals, 0);
	Uint64Array *tags = IoTagDB_tagArrayForTagNames_(self, m, tagNames);
	Uint64Array *keys = TagDB_keysForTags_(tdb, tags);
	UArray *keyArray = UArray_newWithData_type_size_copy_(Uint64Array_data(keys), CTYPE_uint64_t, Uint64Array_size(keys), 1);
	IoSeq *keySeq = IoSeq_newWithUArray_copy_(IOSTATE, keyArray, 0);
	Uint64Array_free(tags);
	return keySeq;
}
Beispiel #21
0
Datei: IoFile.c Projekt: achoy/io
IO_METHOD(IoFile, readBufferOfLength_)
{
	/*doc File readBufferOfLength(aNumber)
	Reads a Buffer of the specified length and returns it.
	Returns Nil if the end of the file has been reached.
	*/

	UArray *ba = IoFile_readUArrayOfLength_(self, locals, m);

	if (!ba)
	{
		return IONIL(self);
	}

	return IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
}
Beispiel #22
0
Datei: IoFile.c Projekt: achoy/io
IO_METHOD(IoFile, reopen)
{
	/*doc File reopen(otherFile, mode)
	Reopens otherFile and redirects its stream to this file's path using mode.
	If mode is omitted, it is copied from otherFile.
	Returns self or raises a File exception on error.
	*/

	IoFile *otherFile;
	IoSeq *mode;

	DATA(self)->flags = IOFILE_FLAGS_NONE;

	IoMessage_assertArgCount_receiver_(m, 1, self);
	
	otherFile = IoMessage_locals_valueArgAt_(m, locals, 0);
	IOASSERT(ISFILE(otherFile), "arg must be a File");
	
	mode = IoMessage_locals_valueArgAt_(m, locals, 1);
	if(ISSEQ(mode))
	{
		DATA(self)->mode = IOREF(mode);
	}
	else
	{
		DATA(self)->mode = IOREF(IoSeq_newWithUArray_copy_(IOSTATE, (UArray *)DATA(DATA(otherFile)->mode), 1));
	}

	if (!DATA(self)->stream)
	{
		FILE *fp = freopen(UTF8CSTRING(DATA(self)->path), CSTRING(DATA(self)->mode), DATA(otherFile)->stream);

		if (fp)
		{
			DATA(self)->stream = fp;
		}
		else
		{
			printf("%i:%s\n", errno, strerror(errno));
			IoState_error_(IOSTATE, m, "unable to reopen to file '%s' with mode %s.", UTF8CSTRING(DATA(self)->path), CSTRING(DATA(self)->mode));
			fclose(fp);
		}
	}

	return self;
}
Beispiel #23
0
Datei: IoFile.c Projekt: achoy/io
IO_METHOD(IoFile, readLine)
{
	/*doc File readLine
	Reads the next line of the file and returns it as a
	string without the return character. Returns Nil if the 
	end of the file has been reached.
	*/

	//char *path = UTF8CSTRING(DATA(self)->path); // tmp for debugging

	IoFile_assertOpen(self, locals, m);

	if (feof(DATA(self)->stream) != 0)
	{
		clearerr(DATA(self)->stream);
		return IONIL(self);
	}
	else
	{
		UArray *ba = UArray_new();
		int error;
		unsigned char didRead = UArray_readLineFromCStream_(ba, DATA(self)->stream);

		if (!didRead)
		{
			UArray_free(ba);
			return IONIL(self);
		}

		error = ferror(DATA(self)->stream);

		if (error != 0)
		{
			UArray_free(ba);
			clearerr(DATA(self)->stream);
			IoState_error_(IOSTATE, m, "error reading from file '%s'", UTF8CSTRING(DATA(self)->path));
			return IONIL(self);
		}

		return IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
		/*return IoState_symbolWithUArray_copy_(IOSTATE, ba, 0);*/
	}
}
Beispiel #24
0
Datei: IoBox.c Projekt: ADTSH/io
IoObject *IoBox_resizeBy(IoBox *self, IoObject *locals, IoMessage *m)
{
	IoSeq *d         = IoMessage_locals_pointArgAt_(m, locals, 0);
	int resizeWidth  = IoMessage_locals_intArgAt_(m, locals, 1);
	int resizeHeight = IoMessage_locals_intArgAt_(m, locals, 2);
	IoSeq *minSize   = IoMessage_locals_valueArgAt_(m, locals, 3);
	IoSeq *maxSize   = IoMessage_locals_valueArgAt_(m, locals, 4);

	UArray *mins = ISNIL(minSize) ? 0x0 : IoSeq_rawUArray(minSize);
	UArray *maxs = ISNIL(maxSize) ? 0x0 : IoSeq_rawUArray(maxSize);

	UArray *outd = IoBox_rawResizeBy(self,
	IoSeq_rawUArray(d),
	resizeWidth, resizeHeight,
	mins, maxs);

	IoSeq *out = IoSeq_newWithUArray_copy_(IOSTATE, outd, 0);

	return out;
}
Beispiel #25
0
IoObject *IoRandom_bytes(IoObject *self, IoObject *locals, IoMessage *m)
{
	/*doc Random bytes(count)
	Returns a Sequence of size count containing random bytes.
	*/

	size_t i, count = IoMessage_locals_sizetArgAt_(m, locals, 0);
	UArray *a;
	uint8_t *d = malloc(count);

	for(i = 0; i < count; i ++)
	{
		d[i] = (uint8_t)(RandomGen_randomInt(DATA(self)) & 255);
	}

	a = UArray_newWithData_type_size_copy_(d, CTYPE_uint8_t, count, 0);
	UArray_setEncoding_(a, CENCODING_NUMBER);

	return IoSeq_newWithUArray_copy_(IOSTATE, a, 0);
}
Beispiel #26
0
IoSeq *IoAVCode_frameSeqForAVFrame_(IoAVCodec *self, AVFrame *avframe, int srcPixelFormat, int width, int height)
{
	AVPicture *rgbPicture = IoAVCode_allocDstPictureIfNeeded(self, srcPixelFormat, width, height);
	AVPicture srcPicture;
	int result;

	memcpy(srcPicture.data,     avframe->data,     sizeof(uint8_t *) * 4);
	memcpy(srcPicture.linesize, avframe->linesize, sizeof(int)       * 4);

	result = img_convert(rgbPicture, PIX_FMT_RGB24, &srcPicture, srcPixelFormat, width, height);

	if (result)
	{
		printf("AVCodec: img_convert error?\n");
	}

	UArray *data = UArray_newWithData_type_encoding_size_copy_(rgbPicture->data[0], CTYPE_uint8_t, CENCODING_NUMBER, width * height * 3, 1);

	return IoSeq_newWithUArray_copy_(IOSTATE, data, 0);
}
Beispiel #27
0
IoObject *IoODEMass_inertiaTensor(IoODEMass *self, IoObject *locals, IoMessage *m)
{
	UArray *u = UArray_new();
	int i, j;

	UArray_setItemType_(u, CTYPE_float32_t);
	UArray_setSize_(u, 9);

	// I == vector(I11, I12, I13, _, I12, I22, I23, _, I13, I23, I33, _)


	for(i = 0, j = 0; i < 12; i++)
	{
		if ((i + 1) % 4)
		{
			UArray_at_putDouble_(u, j++, DATA(self)->I[i]);
		}
	}

	return IoSeq_newWithUArray_copy_(IOSTATE, u, 1);
}
Beispiel #28
0
Datei: IoFile.c Projekt: achoy/io
IO_METHOD(IoFile, asBuffer)
{
	/*doc File asBuffer
	Opens the receiver in read only mode, reads the whole
	contents of the file into a buffer object, closes the file and returns the buffer.
	*/

	UArray *ba = UArray_new();
	long result = UArray_readFromFilePath_(ba, IoSeq_rawUArray(DATA(self)->path));

	if (-1 != result)
	{
		return IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
	}
	else
	{
		UArray_free(ba);
		IoState_error_(IOSTATE, m, "unable to read file '%s'", UTF8CSTRING(DATA(self)->path));
	}

	return IONIL(self);
}
Beispiel #29
0
IO_METHOD(IoSeq, with)
{
	/*doc Sequence with(aSequence, ...)
	Returns a new Sequence which is the concatination of the arguments.
	The returned sequence will have the same mutability status as the receiver.
	*/

	int n, argCount = IoMessage_argCount(m);
	UArray *ba = UArray_clone(DATA(self));

	for (n = 0; n < argCount; n ++)
	{
		IoSeq *v = IoMessage_locals_seqArgAt_(m, locals, n);
		UArray_append_(ba, DATA(v));
	}

	if (ISSYMBOL(self))
	{
		return IoState_symbolWithUArray_copy_(IOSTATE, ba, 0);
	}

	return IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
}
Beispiel #30
0
IO_METHOD(IoSeq, between)
{
	/*doc Sequence betweenSeq(aSequence, anotherSequence)
	Returns a new Sequence containing the bytes between the
	occurrence of aSequence and anotherSequence in the receiver. 
	If aSequence is empty, this method is equivalent to beforeSeq(anotherSequence).
	If anotherSequence is nil, this method is equivalent to afterSeq(aSequence).
	nil is returned if no match is found.
	*/

	long start = 0;
	long end = 0;
	IoSeq *fromSeq, *toSeq;

	fromSeq = (IoSeq *)IoMessage_locals_valueArgAt_(m, locals, 0);

	if (ISSEQ(fromSeq))
	{
		if (IoSeq_rawSize(fromSeq) == 0)
		{
			start = 0;
		}
		else
		{
			start = UArray_find_from_(DATA(self), DATA(fromSeq), 0);

			if (start == -1)
			{
				//start = 0;
				return IONIL(self);
			}
			start += IoSeq_rawSize(fromSeq);
		}
	}
	else if (ISNIL(fromSeq))
	{
		start = 0;
	}
	else
	{
		IoState_error_(IOSTATE, m, "Nil or Sequence argument required for arg 0, not a %s",
					IoObject_name((IoObject *)fromSeq));
	}

	toSeq = (IoSeq *)IoMessage_locals_valueArgAt_(m, locals, 1);

	if (ISSEQ(toSeq))
	{
		end = UArray_find_from_(DATA(self), DATA(toSeq), start);
		//if (end == -1) start = UArray_size(DATA(self));
		if (end == -1) return IONIL(self);
	}
	else if (ISNIL(toSeq))
	{
		end = UArray_size(DATA(self));
	}
	else
	{
		IoState_error_(IOSTATE, m, "Nil or Sequence argument required for arg 1, not a %s",
					IoObject_name((IoObject *)toSeq));
	}

	{
		UArray *ba = UArray_slice(DATA(self), start, end);
		IoSeq *result = IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
		return result;
	}
}