servo / rust-mozjs

DEPRECATED - moved to servo/mozjs instead.
Mozilla Public License 2.0
293 stars 122 forks source link

Make Handle fields private #194

Open jdm opened 9 years ago

jdm commented 9 years ago

It's too easy for inexperienced JSAPI users to turn to manual Handle creation. We should hide the fields and add an unsafe from_rooted_location static method instead, so it's clearer what invariants must be upheld.

frewsxcv commented 9 years ago

'inexperienced JSAPI user' here: I have indeed attempted to do this multiple times

michaelwu commented 9 years ago

Was discussing this on IRC. I think we're close to the point where we can directly determine what fields should be public/private using the original headers. I made all the fields public originally to make things easier to use, but it's probably not necessary now. ptr in Handle<T> is private, so doing this would also fix this issue.