Structures |
Top |
The original is as fast as greased lightning: Offset is calculated at compile time, stuff is put there, finished.
A glance shows the similarity between objects and structures. Indeed C++ objects are structures that contain pointers to functions. So we pick Xbase++ classes/objects to implement the structures.
Two possible approaches:
1. Write straight to memory (was my first approach) Advantages: - Very much like the real thing - Fast from call to call Disadvantages: - Access to members slow - Nested structures problematic - No automatic destruction (Showstopper) - Pointers cannot be easily implemented
2. Store in buffer, build C-structure before call, bring back after call Advantages: - Fast access to members - Pointers can be implemented - Nested structures can be implemented Disadvantage: - Slow when passed on call
So we pick # 2. Don't even think about comparing C structures' speed with my structures.
Denken an:
- alignment - pointers to strings and other structures or arrays - arrays - datentypen - nested structures - freie länge des letzten elements - :Lock() / :Unlock() - :emptybuffer - :buffersize - unions - dynamische gösse mit struct-array am schluss. Die element des struct-arrays können nicht mehr von dynamischer grösse sein, da sonst die adressierung auf den einzelnen struct nicht mehr gehen würde.
- Members at pointer werden bei :New() immer mit NIL initialisiert, auch wenn es Arrays sind, bei :NewFrom(addresse) werden sie in der in der Definition angegebenen Grösse erzeugt und gefüllt.
|