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

Commit 3168fed

Browse filesBrowse files
committed
fix more errors
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
1 parent 0fdd5a8 commit 3168fed
Copy full SHA for 3168fed

File tree

9 files changed

+20
-67
lines changed
Filter options

9 files changed

+20
-67
lines changed

‎vm/src/stdlib/ctypes/array.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/ctypes/array.rs
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::fmt;
2222
use widestring::WideCString;
2323
use crate::class::StaticType;
2424
use crate::convert::IntoObject;
25-
use crate::protocol::PyBuffer;
25+
use crate::protocol::{PyBuffer, PyIter};
2626

2727
// TODO: make sure that this is correct wrt windows and unix wstr
2828
fn slice_to_obj(ty: &str, b: &[u8], vm: &VirtualMachine) -> PyResult {
@@ -209,7 +209,7 @@ fn array_slice_getitem<'a>(
209209
let mut obj_vec = Vec::new();
210210
let mut offset;
211211

212-
for curr in PyIterable::try_from_object(vm,_range.into_object(vm))?.iter(vm)? {
212+
for curr in PyIter::try_from_object(vm,_range.into_object(vm))?.iter(vm)? {
213213
let idx = fix_index(isize::try_from_object(vm, curr?)?, length, vm)? as usize;
214214
offset = idx * size;
215215

@@ -408,7 +408,7 @@ impl PyCArrayMeta {
408408
Err(vm.new_value_error("The '_length_' attribute must not be negative".to_string()))
409409
} else {
410410
Ok(
411-
builtins::int::try_to_primitive(length_int.as_bigint(), vm).map_err(|_| {
411+
try_to_primitive(length_int.as_bigint(), vm).map_err(|_| {
412412
vm.new_overflow_error("The '_length_' attribute is too large".to_owned())
413413
})?,
414414
)

‎vm/src/stdlib/ctypes/basics.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/ctypes/basics.rs
+1-12Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{PyObjectRef, PyPayload, PyRef, PyResult, VirtualMachine};
1212
use crate::stdlib::ctypes::array::make_array_with_length;
1313
use crate::stdlib::ctypes::dll::dlsym;
1414
use crate::stdlib::ctypes::primitive::{new_simple_type, PyCSimple};
15+
use crate::function::Either;
1516

1617
use crate::builtins::PyTypeRef;
1718
use crate::protocol::PyBuffer;
@@ -364,12 +365,6 @@ impl fmt::Debug for RawBuffer {
364365
}
365366
}
366367

367-
impl PyPayload for RawBuffer {
368-
fn class(vm: &VirtualMachine) -> &PyTypeRef {
369-
&vm.ctx.types.object_type
370-
}
371-
}
372-
373368
unsafe impl Send for RawBuffer {}
374369
unsafe impl Sync for RawBuffer {}
375370

@@ -388,12 +383,6 @@ impl fmt::Debug for PyCData {
388383
}
389384
}
390385

391-
impl PyPayload for PyCData {
392-
fn class(_vm: &VirtualMachine) -> &PyTypeRef {
393-
Self::static_type()
394-
}
395-
}
396-
397386
impl PyCData {
398387
pub fn new(objs: Option<Vec<PyObjectRef>>, buffer: Option<RawBuffer>) -> Self {
399388
PyCData {

‎vm/src/stdlib/ctypes/dll.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/ctypes/dll.rs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub(crate) use _ctypes::*;
44
pub(crate) mod _ctypes {
55
use crate::builtins::pystr::PyStrRef;
66
use crate::builtins::PyIntRef;
7-
use crate::VirtualMachine;
7+
use crate::{TryFromObject, PyResult, VirtualMachine};
88

99
use super::super::shared_lib::libcache;
1010

‎vm/src/stdlib/ctypes/function.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/ctypes/function.rs
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,6 @@ impl fmt::Debug for PyCFuncPtr {
254254
}
255255
}
256256

257-
impl PyPayload for PyCFuncPtr {
258-
fn class(_vm: &VirtualMachine) -> &PyTypeRef {
259-
Self::static_type()
260-
}
261-
}
262-
263257
#[pyclass(with(Callable), flags(BASETYPE))]
264258
impl PyCFuncPtr {
265259
#[pygetset(name = "_argtypes_")]
@@ -400,7 +394,9 @@ impl PyCFuncPtr {
400394
}
401395

402396
impl Callable for PyCFuncPtr {
403-
fn call(zelf: &PyRef<Self>, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
397+
type Args = FuncArgs;
398+
399+
fn call(zelf: &PyRef<Self>, args: Self::Args, vm: &VirtualMachine) -> PyResult {
404400
let inner_args = unsafe { &*zelf._argtypes_.as_ptr() };
405401

406402
if args.args.len() != inner_args.len() {

‎vm/src/stdlib/ctypes/mod.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/ctypes/mod.rs
+10-9Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ mod shared_lib;
1010
mod structure;
1111
mod union;
1212

13-
use array::{PyCArray, PyCArrayMeta};
14-
use basics::{addressof, alignment, byref, sizeof_func, PyCData};
15-
use primitive::{PyCSimple, PySimpleMeta};
16-
use structure::PyCStructure;
13+
use array::PyCArrayMeta;
14+
use basics::PyCData;
15+
use primitive::PySimpleMeta;
1716
use crate::class::PyClassImpl;
1817
use crate::convert::IntoObject;
1918

@@ -23,6 +22,7 @@ mod _ctypes {
2322
use crate::function::Either;
2423
use crate::builtins::PyTypeRef;
2524
use crate::{PyObjectRef, PyResult, VirtualMachine};
25+
use crate::stdlib::ctypes::pointer;
2626

2727
#[pyattr(name="__version__")]
2828
pub(crate) fn version() -> &'static str {
@@ -50,22 +50,23 @@ mod _ctypes {
5050
}
5151

5252
#[pyfunction]
53-
pub(crate) fn POINTER(tp: Either<PyTypeRef, PyObjectRef>, vm: &VirtualMachine) -> PyResult {
54-
basics::POINTER(tp, vm)
53+
pub(crate) fn POINTER(tp: PyTypeRef, vm: &VirtualMachine) -> PyResult {
54+
pointer::POINTER(tp);
55+
Ok(vm.get_none())
5556
}
5657

5758
#[pyfunction]
5859
pub(crate) fn pointer(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult {
59-
basics::pointer_fn(obj, vm)
60+
pointer::pointer_fn(obj);
61+
Ok(vm.get_none())
6062
}
6163

6264
#[pyfunction]
6365
pub(crate) fn _pointer_type_cache(vm: &VirtualMachine) -> PyResult {
6466
Ok(PyObjectRef::from(vm.ctx.new_dict()))
6567
}
6668

67-
#[pyclass(name = "CFuncPtr")]
68-
pub(crate) struct CFuncPtr {}
69+
// TODO: add the classes
6970
}
7071

7172
pub(crate) fn make_module(vm: &VirtualMachine) -> PyObjectRef {

‎vm/src/stdlib/ctypes/pointer.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/ctypes/pointer.rs
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt;
22

3+
use crate::PyObjectRef;
34
use crate::builtins::PyTypeRef;
4-
use crate::VirtualMachine;
55

66
use crate::stdlib::ctypes::basics::PyCData;
77

@@ -14,12 +14,6 @@ impl fmt::Debug for PyCPointer {
1414
}
1515
}
1616

17-
impl PyPayload for PyCPointer {
18-
fn class(_vm: &VirtualMachine) -> &PyTypeRef {
19-
Self::static_type()
20-
}
21-
}
22-
2317
// impl PyCDataMethods for PyCPointer {
2418
// fn from_param(zelf: PyRef<Self>, value: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyObjectRef> {
2519

‎vm/src/stdlib/ctypes/primitive.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/ctypes/primitive.rs
+1-12Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::stdlib::ctypes::basics::{
1414
};
1515
use crate::stdlib::ctypes::function::PyCFuncPtr;
1616
use crate::stdlib::ctypes::pointer::PyCPointer;
17+
use crate::function::Either;
1718
use crate::{PyObjectRef, PyRef, PyResult, VirtualMachine};
1819
use crate::protocol::PyBuffer;
1920

@@ -305,18 +306,6 @@ impl fmt::Debug for PySimpleMeta {
305306
}
306307
}
307308

308-
impl PyPayload for PyCSimple {
309-
fn class(_vm: &VirtualMachine) -> &PyTypeRef {
310-
Self::static_type()
311-
}
312-
}
313-
314-
impl PyPayload for PySimpleMeta {
315-
fn class(_vm: &VirtualMachine) -> &PyTypeRef {
316-
Self::static_type()
317-
}
318-
}
319-
320309
impl PyCDataMethods for PySimpleMeta {
321310
// From PyCSimpleType_Type PyCSimpleType_methods
322311
fn from_param(

‎vm/src/stdlib/ctypes/shared_lib.rs

Copy file name to clipboardExpand all lines: vm/src/stdlib/ctypes/shared_lib.rs
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::{collections::HashMap, fmt, os::raw::c_void, ptr::null};
33
use crossbeam_utils::atomic::AtomicCell;
44
use libloading::Library;
55

6-
use crate::builtins::PyTypeRef;
76
use crate::common::lock::PyRwLock;
87
use crate::{PyPayload, PyRef, VirtualMachine};
98
pub struct SharedLibrary {
@@ -22,12 +21,6 @@ impl fmt::Debug for SharedLibrary {
2221
}
2322
}
2423

25-
impl PyPayload for SharedLibrary {
26-
fn class(vm: &VirtualMachine) -> &PyTypeRef {
27-
&vm.ctx.types.object_type
28-
}
29-
}
30-
3124
impl SharedLibrary {
3225
pub fn new(name: &str) -> Result<SharedLibrary, libloading::Error> {
3326
Ok(SharedLibrary {

‎vm/src/stdlib/ctypes/structure.rs

Copy file name to clipboard
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
use std::fmt;
2-
use rustpython_vm::PyPayload;
3-
use crate::builtins::PyTypeRef;
4-
use crate::VirtualMachine;
52

63
use crate::stdlib::ctypes::basics::PyCData;
74

@@ -14,11 +11,5 @@ impl fmt::Debug for PyCStructure {
1411
}
1512
}
1613

17-
impl PyPayload for PyCStructure {
18-
fn class(_vm: &VirtualMachine) -> &PyTypeRef {
19-
Self::static_type()
20-
}
21-
}
22-
2314
#[pyclass(flags(BASETYPE))]
2415
impl PyCStructure {}

0 commit comments

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