Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
temp
  • Loading branch information
youknowone committed Nov 29, 2025
commit 190c4340f99fb2af14d9faa89304e66d8034eb52
18 changes: 18 additions & 0 deletions crates/vm/src/stdlib/ctypes/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,41 @@ pub struct CDataObject {
/// pointer to base object or None (b_base)
#[allow(dead_code)]
pub base: Option<PyObjectRef>,
/// index into base's b_objects list (b_index)
#[allow(dead_code)]
pub index: usize,
/// dictionary of references we need to keep (b_objects)
pub objects: Option<PyObjectRef>,
}

impl CDataObject {
/// Create new owned buffer with zero-initialized memory
pub fn new(size: usize) -> Self {
CDataObject {
buffer: vec![0u8; size],
base: None,
index: 0,
objects: None,
}
}

/// Create from existing bytes (copies data)
pub fn from_bytes(data: Vec<u8>, objects: Option<PyObjectRef>) -> Self {
CDataObject {
buffer: data,
base: None,
index: 0,
objects,
}
}

/// Create from base object (copies data from base's buffer at offset)
#[allow(dead_code)]
pub fn from_base(base: PyObjectRef, _offset: usize, size: usize, index: usize, objects: Option<PyObjectRef>) -> Self {
CDataObject {
buffer: vec![0u8; size],
base: Some(base),
index,
objects,
}
}
Expand Down