Skip to content
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

Per-compartment snapshotting #31

Open
asajeffrey opened this issue Oct 20, 2017 · 0 comments
Open

Per-compartment snapshotting #31

asajeffrey opened this issue Oct 20, 2017 · 0 comments

Comments

@asajeffrey
Copy link
Owner

asajeffrey commented Oct 20, 2017

It would be nice if we could snapshot some compartments, not others. For example when deep-cloning cloning an object from one compartment to another, it would be nice if we could rely on the source compartment being snapshotted, so we could copy from it safely.

At the moment the code to clone an array of objects is https://github.com/asajeffrey/linjs/blob/1bcfc4bfdfd975d00c954c0be29de9172e34c3a2/examples/minidom/minidom.rs#L181-L196

This is tricker than it should be to cover the case where C and D are the same compartment, so updates to the target might change the state of the source, which is why we can't just iterate over the source array. If D was snapshotted but C wasn't then we could write simpler code, something like:

fn clone_children_from<S, D>(self, cx: &'a mut JSContext<S>, element: Element<'a, D>) where
    S: CanAccess + CanAlloc + InCompartment<C> + Snapshotted<'a, D>,
    C: Compartment,
    D: Compartment,
{
    let children = element.0.borrow(cx).children.snapshot(cx);
    for &child in &children {
        self.append_clone(cx, child);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant