void UArray_appendPath_(UArray *self, const UArray *path) { const UArray sep = UArray_stackAllocedWithCString_(IO_PATH_SEPARATOR); int selfEndsWithSep = IS_PATH_SEPERATOR(UArray_lastLong(self)); int pathStartsWithSep = IS_PATH_SEPERATOR(UArray_firstLong(path)); if (!selfEndsWithSep && !pathStartsWithSep) { if(self->size != 0) UArray_append_(self, &sep); UArray_append_(self, path); } else if (selfEndsWithSep && pathStartsWithSep) { const UArray pathPart = UArray_stackRange(path, 1, path->size - 1); UArray_append_(self, &pathPart); } else { UArray_append_(self, path); } }
IO_METHOD(IoSeq, appendSeq) { /*doc Sequence appendSeq(object1, object2, ...) Calls asString on the arguments and appends the string to the receiver. Returns self. */ int i; IO_ASSERT_NOT_SYMBOL(self); IOASSERT(IoMessage_argCount(m), "requires at least one argument"); for (i = 0; i < IoMessage_argCount(m); i ++) { UArray_append_(DATA(self), DATA(IoMessage_locals_valueAsStringArgAt_(m, locals, i))); } return self; }
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); }
void BStream_writeUArray_(BStream *self, UArray *ba) { BStream_writeInt32_(self, UArray_size(ba)); UArray_append_(self->ba, ba); self->index += UArray_size(ba); }