tolua.cast(object, typeName)
tolua.cast treats a bound object as the specified native type:
1 | local node = tolua.cast(layer, "cc.Node") |
This can be useful when an object retrieved through a generic API has lost the more specific Lua-facing methods expected by the caller. The requested type must match the actual C++ inheritance relationship; a cast does not transform an unrelated object.
tolua.type(object)
tolua.type returns the native type description for a bound C++ object:
1 | local node = display.newNode() |
The exact returned name depends on the engine and binding version.
tolua.isnull(object)
A Lua value may remain reachable after its underlying C++ object has been deleted. Calling native methods through that stale binding can fail. Check it first:
1 | if object and not tolua.isnull(object) then |
This check is useful at asynchronous or lifecycle boundaries, but ownership should still be managed carefully so stale native references are not retained longer than necessary.