20,741
edits
No edit summary |
m (→GHOSTs) |
||
Line 54: | Line 54: | ||
ghost (Garbage-collected Handle to OutSide Thingy – a virtual type that represents a C or C++ object). | ghost (Garbage-collected Handle to OutSide Thingy – a virtual type that represents a C or C++ object). | ||
Things get more complicated if you need to pass a handle to a C/C++ object into a Nasal script. There, you need to use a wrapped handle type called a ghost ("Garbage-collectable Handle to an OutSide Thing"), which has a callback that you need to implement to deal with what happens when the Nasal interpreter garbage collects your object. | Things get more complicated if you need to pass a handle to a C/C++ object into a Nasal script. There, you need to use a wrapped handle type called a ghost ("Garbage-collectable Handle to an OutSide Thing"), which has a callback that you need to implement to deal with what happens when the Nasal interpreter garbage collects your object. | ||
Ghosts were never intended to be ‘public’ first-order objects in Nasal, originally. The were more like a void* wrapper so you could safely pass a C pointer around, and pass it to native functions. If you look at props.Node uses them, with a Nasal wrapper, that was the original method. | |||
James Turner added member support to allow them to be used publicly, since it avoids the overhead of the wrapper in many common cases, and Thomas G did some improvements to that. But at no point have we tried to systematically make Ghosts work as a first-order type <ref>https://sourceforge.net/p/flightgear/mailman/message/37063639/</ref> | |||
== Getting started == | == Getting started == |