Sha256: e7aa4aa19580197a02367e3b762652a647d4f897c6ae118f8d982b28e4e28032

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

controller :controller do
  action :index do
    on_entry %{
      original_page = {
        _head: "head",
        _next: "next",
        _id: "id",
        entries: [
          {_id: "id", _sig: "sig"},
          {_id: "id2", _sig: "sig2"},
          {_id: "id3", _sig: "sig3"},
        ],
        _hash: "hash",
      };

      page = CopyPage(original_page);
      EntryMutable(page, 0);
      EntryMutable(page, 2);

      page.entries[0].hello = "world";
      page.entries[2].hello = "world";

      //This is a violation of the vm, it will set the original but not copied
      //This is because the page.entries[1] actually refers to the original_page.entries[1]
      //the array of original_page.entries belongs to original_page, but the entries inside it
      //are references. When you call entrymutable, you are making a copy and replacing that
      //entry in the array so that page.entries[0] is actually owned by page and is no longer apart
      //of original_page
      page.entries[1].foo = "bar";
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flok-0.0.40 spec/kern/assets/vm/macros/entry_mutable_c.rb
flok-0.0.39 spec/kern/assets/vm/macros/entry_mutable_c.rb