Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
array buffer internal with original type
  • Loading branch information
youknowone committed Sep 27, 2021
commit 3952d8cda4874e2323b21739a53a9f91a66fa251
15 changes: 9 additions & 6 deletions vm/src/stdlib/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ mod array {
let array = zelf.read();
let buf = PyBuffer::new(
zelf.as_object().clone(),
zelf.clone(),
PyArrayBufferInternal(zelf.clone()),
BufferOptions {
readonly: false,
len: array.len(),
Expand All @@ -1140,21 +1140,24 @@ mod array {
}
}

impl BufferInternal for PyRef<PyArray> {
#[derive(Debug)]
struct PyArrayBufferInternal(PyRef<PyArray>);

impl BufferInternal for PyArrayBufferInternal {
fn obj_bytes(&self) -> BorrowedValue<[u8]> {
self.get_bytes().into()
self.0.get_bytes().into()
}

fn obj_bytes_mut(&self) -> BorrowedValueMut<[u8]> {
self.get_bytes_mut().into()
self.0.get_bytes_mut().into()
}

fn release(&self) {
self.exports.fetch_sub(1);
self.0.exports.fetch_sub(1);
}

fn retain(&self) {
self.exports.fetch_add(1);
self.0.exports.fetch_add(1);
}
}

Expand Down