What is the best/proper way to obtain a memory block with the contents of an object; either by creating a memory block overlapping the object’s content, or copying the content into a new Memory block.
My goal is to copy the bytes(content) of an object into a memory block for examination of how Xojo does certain alignments among other reasons.
Object can and will have other pointers inside of it, pointing to yet another data. As in…in 99% of cases Object does not just have simple struct data inside of it.
An Object is a virtual entity that physically can be constituted by sparse contents anywhere in the memory, so it’s not a continuous stream of bytes you can copy/past anywhere. People desiring such capability need to implement what is called “serialization”, that means grab an frozen state of an object and convert its properties to a series of bytes that can be deserialized later into a copy of that prior object.
Yes, after a little more thought, Structures are a good solution to the real problem I want to solve. Gives me control over how I do it, not how Xojo does.
Note that Structures behave differently from Objects. When you assign a Structure, you create a copy. This is true whether you pass it as a parameter to a function (unless you use ByRef) or assign it to a different local variable.
Yes, I’m aware of the copy aspect; which is not a problem for me. What concerns me more is efficiency on the M2 processor for things like storing, reading doubles that may or may not be aligned to say 2 or 4 byte offsets. I’m not sure if it matters or I should care.