I suddenly realized the rationale of your suggested approach. It is really a âCOM-likeâ or âCOM-Liteâ way.
The Island-side record acts like an emulated V-Table.
On the C++ side, that Struct has an implicit V-Table pointer in its memory layout.
So, I should really return a pointer of the Island record, and assign that pointer to the C++ Struct (Which actually makes a copy of the Island record pointer, and assigns the copy to that C++ Structâs V-Table pointer).
This also means the life cycle of that Island record can not be ephemeral; it should be of a global nature, i.e the V-table must be there.
It shouldnât copy it no, it should use the pointer. For lifetime: well normally we DO use com, which has the AddRef, Release methods that handle lifetime (those are the IUnknown methods, the other side cleans it up).
What I meant is - in the C++ Structâs memory layout, its v-table pointer is assigned with a value that is actually the value of the Island record v-table pointer.
The size of that C++ Struct is just the same size as its V-table pointer (since it has no data member).
not every fix can be done within 24 hours, and our teams do have a lot on their plates. please be a bit more patient. with literally any other compiler vendor, youâd be looking at a timeline of months, if not years, for a fix like this.
Basically, a struct data member AFTER the first member will be aligned at a boundary that is the minimum of that data memberâs size, or the designated byte number (e.g , 8)
For example, as in the StackOverflow sample (which I donât think they explain the steps clear enough)
struct Pack8Data {
short int a;
double b;
short int c;
int d;
}
b is aligned at min (8,8) = 8, hence offset = 8
c is aligned at min (2,8) = 2, hence offset = 16
d is aligned at min (4,8) = 4, hence offset = 20
SizeOf(Pack8Data) = 24
As we can see, the packing rule is well defined, at least for MSVC compiler.
Is this the same rule implemented by Island compiler? If so, then we are all good.
In any case, even Island does a default 8 byte pack alignment, it is still nice to allow the user to change it to a different value something like C++ PRAGMA or the C++ compiler switch /Zp.
```
namespace OCCIsland;
type
[CallingConvention(CallingConvention.Stdcall)]
ClearSolidsType = public method (aSelf: ^TOccShapeManager);// virtual;
TOccShapeManager = public record
public
ClearSolids : ClearSolidsType; //virtual;
end;
```
How should I assign a function to ClearSolidsType?
method ClearSolidsFunc(aSelf: ^TOccShapeManager);
begin
...
end;
If I set ClearSolids := ClearSolidsFunc; I will get the error saying "E397: No overloaded global function âClearSolidsFuncâ with 0 parameters in namespace xxx
What is the property way to assign function pointer?