Pass Entities to a C-extension

,

By the time most deleted/removed observer callbacks fire, the entity/object has already been deleted. So it, and likely it’s parent are pointing to dummy class objects on the Ruby side and perhaps some dummy struct on the C side.

This is the reason why only the ID is passed. It is expected that extensions will be keeping some collection of their own probably keyed by the integer ID, so this will allow a lookup and allow the extension to deal with the removal.

It is not ideal and so requests have been opened in the API tracker. See what I said yesterday in this post …

FYI: The entities objects in Ruby are so called “thinly wrapped” C++ collections.

No. But I think you may be able to work around it. If you keep a hash of objects and their parents keyed by ID. Then pass the parent entity (model or component definition for groups and instances) and on the C-side get the entities collection via the normal C API functions:

It can be more observer code keeping track of everything.