638
edits
(→Conversions: "reference" -> "CData object" continued) |
(→Proposal 2: De-emphasize aliasing but provide an example.) |
||
| Line 219: | Line 219: | ||
A <code>CData</code> object represents a C/C++ value located in memory. The address of the C/C++ value can be taken, and it can be assigned to. | A <code>CData</code> object represents a C/C++ value located in memory. The address of the C/C++ value can be taken, and it can be assigned to. | ||
''(TODO)'' | ''(TODO)'' | ||
| Line 253: | Line 251: | ||
''(TODO: Pointer types might need some properties of their own.)'' | ''(TODO: Pointer types might need some properties of their own.)'' | ||
It is possible for multiple <code>CData</code> objects to refer to the same memory. (In this way they are sort of like C++ references.) For example: | |||
const Point = new ctypes.StructType( | |||
"Point", [[ctypes.int32_t, 'x'], [ctypes.int32_t, 'y']]); | |||
const Rect = new ctypes.StructType( | |||
"Rect", [[Point, 'topLeft'], [Point, 'bottomRight']]); | |||
var r = Rect(); // a new CData object of type Rect | |||
r.topLeft.x = 100; // This works because r.topLeft is a CData object | |||
// that refers to the topLeft member of r, not a copy. | |||
r.toSource() | |||
===> "Rect({topLeft: Point({x: 100, y: 0}), bottomRight: Point({x: 0, y: 0})})" | |||
Minutiae: | Minutiae: | ||
edits