-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lua_setuserdatatag to update userdata tags #588
Conversation
Are you using this in combination with |
At the moment I use only PS Also would be useful to remove/update inline destructors for userdata but seems the name |
The reason I mention this is that the newly-added function has odd interaction with userdata with custom dtors (created via It's impossible to change the status of "does the userdata have a dtor?" after its created because the dynamically specified dtor takes extra space. It would be possible to disable destructor for a userdata that was previously created with one, I suppose (but that would probably best be done with a different API). This can be prevented by asserting that the tag of the userdata isn't equal to UTAG_IDTOR (or, more generally, that the userdata tag is less then UTAG_LIMIT). Could you explain the use of this function in more detail? In general tags were added to make it easier for the host to identify the type of different userdata objects (which usually also means the size of the userdata is different), so it's a little odd to support tag switching - but maybe if I understand the full use case it would make more sense, or there would be some alternative solution. |
In HashMap<*const c_void, TypeId> where When user try to borrows an instance of
It works just fine, but also, in Rust, What I try to do, is to optimize this a bit and use advantage of tags provided by Luau:
For destructed userdata objects I planned to attach a tag So I need a way to change tags assigned to userdata objects in order to mark them as destructed. |
Got it, thanks - this makes sense now, and seems like a good approach for this use-case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
It could be useful to update userdata tags, for example if change underlying type.
I plan to use this in Rust in mlua in order to mark userdata as destructed (and avoid running destructors).