Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2baeb3e

Browse filesBrowse files
committed
_ctypes.addressof
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
1 parent b2abb1a commit 2baeb3e
Copy full SHA for 2baeb3e

File tree

1 file changed

+10
-0
lines changed
Filter options

1 file changed

+10
-0
lines changed

‎vm/src/stdlib/ctypes.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/ctypes.rs
+10
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,16 @@ pub(crate) mod _ctypes {
214214
}
215215
}
216216

217+
#[pyfunction]
218+
fn addressof(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<usize> {
219+
if obj.is_instance(PyCSimple::static_type().as_ref(), vm)? {
220+
let simple = obj.downcast_ref::<PyCSimple>().unwrap();
221+
Ok(simple.value.as_ptr() as usize)
222+
} else {
223+
Err(vm.new_type_error("expected a ctypes instance".to_string()))
224+
}
225+
}
226+
217227
#[pyfunction]
218228
fn get_errno() -> i32 {
219229
errno::errno().0

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.