| 636 | } |
| 637 | |
| 638 | void ObjectReference::init(LayoutBase* referencedLayout, uint8* preallocatedData, bool resetToDefault) |
| 639 | { |
| 640 | allocator = referencedLayout->allocator; |
| 641 | data = preallocatedData; |
| 642 | |
| 643 | layoutReference = referencedLayout; |
| 644 | layout = referencedLayout->layout; |
| 645 | typeHash = Helpers::createHash(layout); |
| 646 | |
| 647 | jassert(allocator->validMemoryAccess(data)); |
| 648 | jassert(allocator->validMemoryAccess(data + getElementSizeInBytes() - 1)); |
| 649 | |
| 650 | initResult = Result::ok(); |
| 651 | |
| 652 | if (!isValid()) |
| 653 | return; |
| 654 | |
| 655 | for (auto l : layoutReference->layout) |
| 656 | { |
| 657 | if (data != nullptr && resetToDefault) |
| 658 | l->resetToDefaultValue(data); |
| 659 | |
| 660 | auto m = new MemberReference(l, data, -1); |
| 661 | memberReferences.set(l->id, var(m)); |
| 662 | } |
| 663 | |
| 664 | elementSize = getElementSizeInBytes(); |
| 665 | } |
| 666 | |
| 667 | void ObjectReference::reset() |
| 668 | { |
no test coverage detected