import "Container"
-#define Tsize ((class(T).type == noHeadClass || class(T).type == normalClass) ? sizeof(void *) : class(T).typeSize)
+default:
+extern int __ecereVMethodID_class_OnUnserialize;
+private:
public class Array : Container
{
delete array;
}
+ void OnUnserialize(IOChannel channel)
+ {
+ Array array = eInstance_New(_class.fullName);
+ uint count, c;
+ Class Dclass = class(D);
+ channel.Get(count);
+ //printf("%d %ss\n", count, Dclass.name);
+ if(count > 10000)
+ printf("Bug");
+ array.size = count;
+ for(c = 0; c < count; c++)
+ ((void (*)(void *, void *, void *))(void *)Dclass._vTbl[__ecereVMethodID_class_OnUnserialize])
+ (Dclass, ((byte *)array.array) + Dclass.typeSize * c, channel);
+ this = array;
+ }
+
// Generic iterator support
IteratorPointer GetFirst() { return (IteratorPointer)array; }
IteratorPointer GetLast() { return (IteratorPointer)(array ? (array + (count - 1)) : null); }
*item = value;
return true;
}
- IteratorPointer GetAtPosition(I pos, bool create)
+ IteratorPointer GetAtPosition(const I pos, bool create, bool * justAdded)
{
if((int)pos > count && create)
{
if((int)pos + 1 > minAllocSize)
array = renew array T[(int)pos + 1];
count = (int)pos + 1;
+ if(justAdded) *justAdded = true;
}
return ((int)pos < count && array) ? (IteratorPointer)(array + (int)pos) : null;
}
array = renew array T[count + 1];
if(after) after = array + offset;
}
- memmove(after ? (after + 2) : (array + 1), after ? (after + 1) : array, (count - offset) * Tsize);
+ memmove(after ? (after + 2) : (array + 1), after ? (after + 1) : array, (count - offset) * class(T).typeSize);
if(after)
after[1] = value;
else
count++;
return (IteratorPointer)(after ? (after + 1) : array);
*/
- uint tsize = Tsize;
+ uint tsize = class(T).typeSize;
byte * pos = ip ? ((byte *)ip + tsize) : (byte *)array;
if(count+1 > minAllocSize)
{
void Remove(IteratorPointer ip)
{
T * it = (T *)ip;
- memmove(it, it + 1, (count - (it - array) - 1) * Tsize);
+ memmove(it, it + 1, (count - (it - array) - 1) * class(T).typeSize);
count--;
if(count + 1 > minAllocSize)
array = renew array T[count];
if(value > minAllocSize)
array = renew0 array T[value];
else if(value > count)
- memset(array + count, 0, (value - count) * Tsize);
+ memset((byte *)array + count * class(T).typeSize, 0, (value - count) * class(T).typeSize);
count = value;
}
}
if((source._class == class(BuiltInContainer) && ((struct BuiltInContainer *)source)->type.type != structClass ) ||
eClass_IsDerived(source._class, class(Array)))
{
- memcpy(array, ((Array)source).array, count * Tsize);
+ memcpy(array, ((Array)source).array, count * class(T).typeSize);
}
else
{