Skip to content

Allow compiling VM for wasm32-unknown-unknown #311

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

Merged
merged 1 commit into from
Feb 23, 2019
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
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ fn shell_exec(vm: &mut VirtualMachine, source: &str, scope: PyObjectRef) -> bool
true
}

#[cfg(not(target_family = "unix"))]
#[cfg(not(unix))]
fn get_history_path() -> PathBuf {
//Path buffer
PathBuf::from(".repl_history.txt")
}

#[cfg(target_family = "unix")]
#[cfg(unix)]
fn get_history_path() -> PathBuf {
//work around for windows dependent builds. The xdg crate is unix specific
//so access to the BaseDirectories struct breaks builds on python.
Expand Down
18 changes: 14 additions & 4 deletions vm/src/stdlib/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ use super::super::obj::objtype;
use super::super::pyobject::{PyContext, PyFuncArgs, PyObjectRef, PyResult, TypeProtocol};
use super::super::vm::VirtualMachine;

#[cfg(target_family = "unix")]
#[cfg(unix)]
pub fn raw_file_number(handle: File) -> i64 {
use std::os::unix::io::IntoRawFd;

i64::from(handle.into_raw_fd())
}

#[cfg(target_family = "unix")]
#[cfg(unix)]
pub fn rust_file(raw_fileno: i64) -> File {
use std::os::unix::io::FromRawFd;

unsafe { File::from_raw_fd(raw_fileno as i32) }
}

#[cfg(target_family = "windows")]
#[cfg(windows)]
pub fn raw_file_number(handle: File) -> i64 {
use std::os::windows::io::IntoRawHandle;

handle.into_raw_handle() as i64
}

#[cfg(target_family = "windows")]
#[cfg(windows)]
pub fn rust_file(raw_fileno: i64) -> File {
use std::ffi::c_void;
use std::os::windows::io::FromRawHandle;
Expand All @@ -46,6 +46,16 @@ pub fn rust_file(raw_fileno: i64) -> File {
unsafe { File::from_raw_handle(raw_fileno as *mut c_void) }
}

#[cfg(all(not(unix), not(windows)))]
pub fn rust_file(raw_fileno: i64) -> File {
unimplemented!();
}

#[cfg(all(not(unix), not(windows)))]
pub fn raw_file_number(handle: File) -> i64 {
unimplemented!();
}

pub fn os_close(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(vm, args, required = [(fileno, Some(vm.ctx.int_type()))]);

Expand Down