Пример #1
0
IoSymbol *IoSeq_rawAsUntriquotedSymbol(IoSeq *self)
{
	UArray *a = UArray_clone(DATA(self));
	UArray_unquote(a);
	UArray_unquote(a);
	UArray_unquote(a);
	return IoState_symbolWithUArray_copy_(IOSTATE, a, 0);
}
Пример #2
0
IoSeq *IoSeq_rawClone(IoSeq *proto)
{
	if (ISSYMBOL(proto))
	{
		return proto;
	}
	else
	{
		IoSeq *self = IoObject_rawClonePrimitive(proto);
		IoObject_setDataPointer_(self, UArray_clone(DATA(proto)));
		return self;
	}
}
Пример #3
0
IoSymbol *IoSeq_rawAsUnquotedSymbol(IoSeq *self)
{
	UArray *a = UArray_clone(DATA(self));
	/*
	UArray *sa = DATA(self);
	UArray *a = UArray_new();
	UArray_setItemType_(a, UArray_itemType(sa));
	UArray_setEncoding_(a, UArray_encoding(sa));
	UArray_setSize_(a, UArray_size(sa));
	UArray_copy_(a, sa);
	*/
	UArray_unquote(a);
	return IoState_symbolWithUArray_copy_(IOSTATE, a, 0);
}
Пример #4
0
IoRegexMatches *IoRegexMatches_rawClone(IoRegexMatches *proto)
{
	IoObject *self = IoObject_rawClonePrimitive(proto);
	IoObject_setDataPointer_(self, calloc(1, sizeof(IoRegexMatchesData)));

	if (!ISNIL(DATA(proto)->regex))
		DATA(self)->regex = IOREF(DATA(proto)->regex);
	else
		DATA(self)->regex = IONIL(self);
	DATA(self)->string = IOREF(DATA(proto)->string);

	DATA(self)->captureArray = UArray_clone(DATA(proto)->captureArray);
	return self;
}
Пример #5
0
Файл: IoDate.c Проект: bomma/io
IoDate *IoDate_fromSerialization(IoDate *self, IoObject *locals, IoMessage *m)
{
	/*doc Date fromSerialization
	Sets the date based on the serialization sequence.  Return self.
	*/
	
	IoSeq *serializationSeq = IoMessage_locals_seqArgAt_(m, locals, 0);
	UArray *serialization = UArray_clone(IoSeq_rawUArray(serializationSeq));
	
	UArray_setItemType_(serialization, CTYPE_int32_t);
	if(UArray_size(serialization) != 4)
	{
		IoState_error_(IOSTATE, self, "Expected a serialization sequence comprising 4 int32 items.");
	}
	
	Date_fromSerialization(DATA(self), serialization);
	
	UArray_free(serialization);
	
	return self;
}
Пример #6
0
IoObject *IoTokyoCabinetPrefixCursor_last(IoObject *self, IoObject *locals, IoMessage *m)
{
	/*doc TokyoCabinetPrefixCursor last
	Move cursor to last record. Returns self
	*/

	IoSeq *prefix = IoObject_getSlot_(self, IOSYMBOL("prefix"));
	IOASSERT(ISSEQ(prefix), "prefix must be a sequence");
	IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
	
	{
		UArray *p = UArray_clone(IoSeq_rawUArray(prefix));
		UArray_appendCString_(p, " "); // space preceeds .
		
		tcbdbcurjump(TokyoCabinetPrefixCursor(self), (const void *)UArray_bytes(p), (int)UArray_size(p));
		
		UArray_free(p);
	}
	
	return IOBOOL(self, IoTokyoCabinetPrefixCursor_keyBeginsWithPrefix_(self, prefix));
}
Пример #7
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);
}
Пример #8
0
IoObject *IoTokyoCabinetPrefixCursor_jump(IoObject *self, IoObject *locals, IoMessage *m)
{
	/*doc TokyoCabinetPrefixCursor jump(key)
	Move cursor to record before key. Returns self
	*/
	
	IoSeq *key = IoMessage_locals_seqArgAt_(m, locals, 0);
	int result;
	UArray *p;
	
	IoSeq *prefix = IoObject_getSlot_(self, IOSYMBOL("prefix"));
	IOASSERT(ISSEQ(prefix), "prefix must be a sequence");

	p = UArray_clone(IoSeq_rawUArray(prefix));
	UArray_appendPath_(p, IoSeq_rawUArray(key));
	
	result = tcbdbcurjump(TokyoCabinetPrefixCursor(self), 
						  (const void *)UArray_bytes(p), 
						  (int)UArray_sizeInBytes(p));
	UArray_free(p);
	
	IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
	return IOBOOL(self, result);
}
Пример #9
0
IoObject *IoDirectory_justFullPath(IoDirectory *self, IoSymbol *name)
{
    UArray *fullPath = UArray_clone(IoSeq_rawUArray(DATA(self)->path));
    UArray_appendPath_(fullPath, IoSeq_rawUArray(name));
    return IoState_symbolWithUArray_copy_(IOSTATE, fullPath, 0);
}
Пример #10
0
UArray *UArray_asUnixPath(UArray *self)
{
	UArray *a = UArray_clone(self);
	UArray_replaceCString_withCString_(a, OS_PATH_SEPARATOR, IO_PATH_SEPARATOR);
	return a;
}