Skip to content

Navigation Menu

Sign in
Appearance settings

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

Ctypes implementation #2364

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

Open
wants to merge 57 commits into
base: main
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
41b30de
metaclass support for #[pyclass] macro
youknowone Aug 7, 2021
b4a1b80
Initial ctypes module structure with dlopen and dlsym
rodrigocam Oct 29, 2020
b9ada0a
Refactoring ctypes module to a PyPy-like file tree
darleybarreto Oct 31, 2020
1fa7e80
Add __getattr__ to deal with attributes at runtime
rodrigocam Oct 31, 2020
b30dbae
Adding a very basic and initial implementation of _SimpleCData and Fu…
darleybarreto Nov 2, 2020
89587f0
Add PyFuncPtr tp_new from DLL and basic tp_call
rodrigocam Nov 3, 2020
b4ddf4d
Adding basic functions to call libffi-rs
darleybarreto Nov 4, 2020
9177473
Fix compile errors
rodrigocam Nov 5, 2020
14b08b9
Changing some pieces of SharedLibrary
darleybarreto Nov 7, 2020
8adf4dd
Fixing some ref problems in functions.rs
darleybarreto Nov 8, 2020
4341c97
Cahnge PyRc to PyRef in data cache
rodrigocam Nov 10, 2020
eb8541c
Fixing arg type casting
darleybarreto Nov 10, 2020
e38b0a8
Refactoring PyCFuncPtr
darleybarreto Nov 12, 2020
c2df5de
Moving dlsym to from_dll
darleybarreto Nov 12, 2020
fa6b19b
Adding proper *mut c_void casting
darleybarreto Nov 13, 2020
7d220c3
Adding 'reopen' lib
darleybarreto Nov 13, 2020
0a92095
Adding function call
darleybarreto Nov 13, 2020
8ceffd9
Fixing clippy warnings
darleybarreto Nov 14, 2020
4c585ab
Fixing dangling ref
darleybarreto Nov 15, 2020
b09ebe0
Starting primitive types impl
darleybarreto Nov 19, 2020
d7888f9
Adding metaclass
darleybarreto Nov 19, 2020
145afc7
Adding PyCDataMethods trait
darleybarreto Nov 21, 2020
aff291f
Adding default value for PySimpleType
darleybarreto Nov 22, 2020
d29c3bf
Adding some comments
darleybarreto Nov 23, 2020
6fdffab
Implement PySimpleType __init__
darleybarreto Nov 26, 2020
568c838
Modifying Buffer for PyCData
darleybarreto Nov 29, 2020
fb07e53
Adding methods for PyCDataMethods
darleybarreto Nov 30, 2020
6122e40
Adding PyCData_NewGetBuffer related code
darleybarreto Dec 4, 2020
6a4f881
Fixing small fixes
darleybarreto Dec 4, 2020
e2e0ac8
Testing PySimpleType basic functionalities
darleybarreto Dec 5, 2020
c1324ce
Refactoring SharedLibrary
darleybarreto Dec 5, 2020
3f40466
Fixing several bugs
darleybarreto Dec 5, 2020
3e52625
Fixing function call
darleybarreto Dec 6, 2020
3454751
Fixing more of function calls
darleybarreto Dec 6, 2020
0f25f4d
PySimpleType from_param initial commit
darleybarreto Dec 7, 2020
c4f27fb
Adding more methods to PySimpleType
darleybarreto Dec 7, 2020
b88e544
Minor fixes to get compiling on master
coolreader18 Dec 9, 2020
4ce1123
Use static_cell for libcache
coolreader18 Dec 13, 2020
e528fe7
Adding RawBuffer & reworking low level function call
darleybarreto Dec 19, 2020
420a67a
Small fixes
darleybarreto Dec 21, 2020
d656650
Initial commit for PyCArray
darleybarreto Dec 21, 2020
2a1f6d7
Reworking CData buffers
darleybarreto Dec 30, 2020
ed44269
Adding PyCArray setitem
darleybarreto Dec 31, 2020
4d2c678
Adding some helper functions and initial tests
darleybarreto Dec 31, 2020
2c440b3
Adding PyCArray's from_param
darleybarreto Jan 1, 2021
0b65e0d
Adding several changes to make some tests pass
darleybarreto Jan 2, 2021
7c529af
Fix build on master
youknowone Aug 6, 2021
fe01b1a
hide ctypes test
youknowone Aug 6, 2021
25e0403
clean up ctypes::array
youknowone Aug 7, 2021
efabe9b
skeleton PyCSimpleType
youknowone Aug 7, 2021
b79477a
submodule extension for ctypes::dll
youknowone Aug 7, 2021
2904015
Merge pull request #4 from youknowone/dll-submodule
darleybarreto Aug 7, 2021
66a91cb
Add all tests from CPython and PyPy
darleybarreto Aug 8, 2021
577c5ae
Add suggestions and bump dependencies
darleybarreto Aug 8, 2021
6eb0794
Starting to add Metas to primitive and array ctypes
darleybarreto Aug 8, 2021
5916218
Fixing some terribly wrong impls and bugs.
darleybarreto Aug 15, 2021
c2ba116
Fix compilation
darleybarreto Aug 21, 2021
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
Refactoring ctypes module to a PyPy-like file tree
  • Loading branch information
darleybarreto authored and youknowone committed Aug 7, 2021
commit b9ada0a0e16a0f21e99ad24adc18680fa5d7e94e
49 changes: 0 additions & 49 deletions 49 vm/src/stdlib/ctypes.rs

This file was deleted.

Empty file added 0 vm/src/stdlib/ctypes/array.rs
Empty file.
Empty file added 0 vm/src/stdlib/ctypes/basics.rs
Empty file.
Empty file added 0 vm/src/stdlib/ctypes/common.rs
Empty file.
Empty file added 0 vm/src/stdlib/ctypes/ctypes.rs
Empty file.
36 changes: 36 additions & 0 deletions 36 vm/src/stdlib/ctypes/dll.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
extern crate libloading;
use crate::builtins::pystr::PyStrRef;
use crate::builtins::pytype::PyTypeRef;
use crate::pyobject::{PyObjectRef, PyResult, PyValue};
use crate::VirtualMachine;

// #[pyclass()]
#[derive(Debug)]
struct SharedLibrary {
lib: libloading::Library,
}

impl PyValue for SharedLibrary {
fn class(vm: &VirtualMachine) -> &PyTypeRef {
&vm.ctx.types.object_type
}
}

pub fn dlopen(lib_path: PyStrRef, vm: &VirtualMachine) -> PyResult {
let shared_lib = SharedLibrary {
lib: libloading::Library::new(lib_path.as_ref()).expect("Failed to load library"),
};
Ok(vm.new_pyobj(shared_lib))
}

pub fn dlsym(handle: PyObjectRef, func_name: PyStrRef) {
if let Some(slib) = handle.payload::<SharedLibrary>() {
unsafe {
let func: libloading::Symbol<extern "C" fn()> = slib
.lib
.get(func_name.as_ref().as_bytes())
.expect("Failed to get func");
func();
}
}
}
Empty file.
15 changes: 15 additions & 0 deletions 15 vm/src/stdlib/ctypes/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::pyobject::PyObjectRef;
use crate::VirtualMachine;

mod dll;

use crate::stdlib::ctypes::dll::*;

pub(crate) fn make_module(vm: &VirtualMachine) -> PyObjectRef {
let ctx = &vm.ctx;

py_module!(vm, "_ctypes", {
"dlopen" => ctx.new_function(dlopen),
"dlsym" => ctx.new_function(dlsym),
})
}
Empty file added 0 vm/src/stdlib/ctypes/pointer.rs
Empty file.
Empty file.
Empty file.
Empty file added 0 vm/src/stdlib/ctypes/union.rs
Empty file.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.