Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ siphasher = "0.3"
rand = "0.8"
volatile = "0.3"
radium = "0.6"
libc = "0.2.101"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest version of libc is 0.2.102 as of when I'm writing this comment. (See also #3050.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used current version for consistency between RustPython crates and not to make conflict

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There wouldn't be conflict anyway; they'd all be upgraded when anything begins to require a newer version. This looks fine to me.

7 changes: 7 additions & 0 deletions common/src/str.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
use std::ops::{Bound, RangeBounds};

#[cfg(not(target_arch = "wasm32"))]
#[allow(non_camel_case_types)]
pub type wchar_t = libc::wchar_t;
#[cfg(target_arch = "wasm32")]
#[allow(non_camel_case_types)]
pub type wchar_t = u32;

pub fn try_get_chars(s: &str, range: impl RangeBounds<usize>) -> Option<&str> {
let mut chars = s.chars();
let start = match range.start_bound() {
Expand Down
9 changes: 1 addition & 8 deletions vm/src/stdlib/array.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
pub(crate) use array::make_module;

#[cfg(not(target_arch = "wasm32"))]
#[allow(non_camel_case_types)]
pub type wchar_t = libc::wchar_t;
#[cfg(target_arch = "wasm32")]
#[allow(non_camel_case_types)]
pub type wchar_t = u32;

#[pymodule(name = "array")]
mod array {
use crate::buffer::{BufferOptions, PyBuffer, PyBufferInternal, ResizeGuard};
Expand All @@ -22,12 +15,12 @@ mod array {
PyMappedRwLockReadGuard, PyMappedRwLockWriteGuard, PyRwLock, PyRwLockReadGuard,
PyRwLockWriteGuard,
};
use crate::common::str::wchar_t;
use crate::function::OptionalArg;
use crate::sliceable::{
saturate_index, PySliceableSequence, PySliceableSequenceMut, SequenceIndex,
};
use crate::slots::{AsBuffer, Comparable, Iterable, PyComparisonOp, PyIter, SlotConstructor};
use crate::stdlib::array::wchar_t;
use crate::{
IdProtocol, IntoPyObject, PyComparisonValue, PyIterable, PyObjectRef, PyRef, PyResult,
PyValue, StaticType, TryFromObject, TypeProtocol,
Expand Down
2 changes: 1 addition & 1 deletion vm/src/stdlib/pystruct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ pub(crate) mod _struct {
pystr::PyStrRef, pytype::PyTypeRef, tuple::PyTupleRef,
};
use crate::byteslike::{ArgBytesLike, ArgMemoryBuffer};
use crate::common::str::wchar_t;
use crate::exceptions::PyBaseExceptionRef;
use crate::function::Args;
use crate::slots::{PyIter, SlotConstructor};
use crate::stdlib::array::wchar_t;
use crate::utils::Either;
use crate::VirtualMachine;
use crate::{IntoPyObject, PyObjectRef, PyRef, PyResult, PyValue, StaticType, TryFromObject};
Expand Down