Merge pull request #3105 from youknowone/wchar-t

extract wchar_t definition to rustpython-common
This commit is contained in:
Noa
2021-09-21 20:14:19 -05:00
committed by GitHub
5 changed files with 11 additions and 9 deletions

1
Cargo.lock generated
View File

@@ -1793,6 +1793,7 @@ dependencies = [
"cfg-if 1.0.0",
"hexf-parse",
"lexical-core",
"libc",
"lock_api",
"num-bigint",
"num-complex",

View File

@@ -21,3 +21,4 @@ siphasher = "0.3"
rand = "0.8"
volatile = "0.3"
radium = "0.6"
libc = "0.2.101"

View File

@@ -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() {

View File

@@ -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};
@@ -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,

View File

@@ -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};