|
78 | 78 | expose TColor = (red, green, blue); // and on enums, sets, ranges, aliases... |
79 | 79 | ``` |
80 | 80 |
|
| 81 | +#### Where `expose` can be used |
| 82 | + |
| 83 | +The keyword is a generic prefix: parser sets a boolean before reading the type, and the resulting `tdef` (whatever kind) gets `df_expose_rtti`. So `expose` works in front of every kind of type Pascal allows in a `type` block: |
| 84 | + |
| 85 | +| Type kind | Example | |
| 86 | +|---|---| |
| 87 | +| class | `expose TForm1 = class(TForm) ... end;` | |
| 88 | +| object | `expose TOldObj = object ... end;` | |
| 89 | +| interface | `expose IFoo = interface ... end;` | |
| 90 | +| record | `expose TPoint = record x, y: integer; end;` | |
| 91 | +| class helper | `expose TStrHelper = class helper for string ... end;` | |
| 92 | +| record / type helper | `expose THelp = record helper for integer ... end;` | |
| 93 | +| enumeration | `expose TColor = (red, green, blue);` | |
| 94 | +| subrange | `expose TDay = 1..7;` | |
| 95 | +| set | `expose TColors = set of TColor;` | |
| 96 | +| static array | `expose TBuf = array[0..15] of byte;` | |
| 97 | +| dynamic array | `expose TIntArr = array of integer;` | |
| 98 | +| pointer | `expose PNode = ^TNode;` | |
| 99 | +| procedural / procvar | `expose TCallback = procedure(x: integer) of object;` | |
| 100 | +| weak alias | `expose TMyInt = integer;` | |
| 101 | +| strong alias | `expose TMyInt = type integer;` | |
| 102 | +| generic | `expose generic TList<T> = class ... end;` | |
| 103 | +| file type | `expose TLogFile = file of TRecord;` | |
| 104 | + |
| 105 | +What gets kept depends on the type kind, because of the propagation rules - exposing a class keeps its property/method/field/method-param names; exposing an enum keeps its value names; exposing a procvar keeps its parameter names; exposing a record keeps the type name. See the propagation rules above. |
| 106 | + |
81 | 107 | The keyword is gated on `m_unleashed`, not on `m_strip_rtti`. That means: |
82 | 108 |
|
83 | 109 | - In any other mode, `expose` is a regular identifier - existing code with a field, variable, or routine called `expose` keeps compiling. |
|
0 commit comments