i(intp.Arrays().begin()), end(intp.Arrays().end());
i != end; ++i) {
Array array;
+ array.typeId = i->typeId;
array.size = i->size;
array.ref = i->ref;
Write(out, &array, sizeof(Array));
Array array;
for (; out && out.tellg() < fileHeader.arraysEnd;) {
out.read(reinterpret_cast<char *>(&array), sizeof(Array));
- if (!array.ref) {
- out.seekg(array.size);
- continue;
+ if (array.ref) {
+ buffer = new char[array.size];
+ unsigned int pos = out.tellg();
+ out.seekg(pos);
+ out.read(buffer, array.size);
+ RelocateArray(buffer, array.size);
+ out.seekp(pos);
+ out.write(buffer, array.size);
+ out.seekg(out.tellp());
+ delete[] buffer;
+ } else {
+ const TypeDescription &td = TypeDescription::Get(array.typeId);
+ for (char *i = array.Data(), *end = array.Data() + array.size;
+ i < end; i += td.Size()) {
+ Relocate(i, td);
+ }
}
- buffer = new char[array.size];
- unsigned int pos = out.tellg();
- out.seekg(pos);
- out.read(buffer, array.size);
- RelocateArray(buffer, array.size);
- out.seekp(pos);
- out.write(buffer, array.size);
- out.seekg(out.tellp());
- delete[] buffer;
}
}
int arraySize(i->second->GetLiteral().ArraySize());
size_t memberSize = fd.IsReferenced() ? sizeof(char *) : fieldType.Size();
Array array;
+ array.typeId = fd.TypeId();
array.size = arraySize * memberSize;
array.data = alloc.Alloc(array.size);
array.ref = fd.IsReferenced();
void Loader::LoadArrays(char *src, Array *begin, Array *end) {
for (Array *i = begin; i < end; i = i->Next()) {
- if (!i->ref) {
- continue;
- }
- for (char *j = i->Data(), *end = i->Data() + i->size;
- j < end; j += sizeof(void *)) {
- *reinterpret_cast<char **>(j) =
- src + *reinterpret_cast<unsigned int *>(j);
+ if (i->ref) {
+ for (char *j = i->Data(), *end = i->Data() + i->size;
+ j < end; j += sizeof(void *)) {
+ *reinterpret_cast<char **>(j) =
+ src + *reinterpret_cast<unsigned int *>(j);
+ }
+ } else {
+ const TypeDescription &td = TypeDescription::Get(i->typeId);
+ for (char *j = i->Data(), *end = i->Data() + i->size;
+ j < end; j += td.Size()) {
+ LoadObject(src, j, td);
+ }
}
}
}