Is it possible for a piece of lua user data to hold reference to a lua object? (Like a table, or another piece of user data?). Basically, what I want to know is:
Can I create a piece of userdata in such a way taht when the gc runs, the user data can say: "Hey! I'm holding references to these other objects, mark them as well."
Thanks!
EDIT: responding to lhf:
Suppose I have:
struct Vertex {
double x, y, z;
}
struct Quaternion {
double w, x, y, z;
}
Now, I can do:
struct Foo {
Vertex v;
Quaternion q;
}
but suppose instead I want:
struct Bar {
Vertex *v;
Quaternion *q;
}
[i.e. suppose Vertex & Quaternion are really big pieces of userdata].
Now, suppose I have a lua user function that takes a userdata Vertex, and a userdata Quaternion, and creates a userdata Bar (I d9n't want a userdata Foo since I want to save the space) -- then I need somehow for the userdata Vertex*/Quaternion* to not be gc-ed.