]>
git.proxmox.com Git - rustc.git/blob - src/libstd/sys/wasm/args.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use marker
::PhantomData
;
16 pub unsafe fn init(_argc
: isize, _argv
: *const *const u8) {
17 // On wasm these should always be null, so there's nothing for us to do here
20 pub unsafe fn cleanup() {
23 pub fn args() -> Args
{
24 // When the runtime debugging is enabled we'll link to some extra runtime
25 // functions to actually implement this. These are for now just implemented
26 // in a node.js script but they're off by default as they're sort of weird
27 // in a web-wasm world.
30 iter
: Vec
::new().into_iter(),
31 _dont_send_or_sync_me
: PhantomData
,
35 // You'll find the definitions of these in `src/etc/wasm32-shim.js`. These
36 // are just meant for debugging and should not be relied on.
38 fn rust_wasm_args_count() -> usize;
39 fn rust_wasm_args_arg_size(a
: usize) -> usize;
40 fn rust_wasm_args_arg_fill(a
: usize, ptr
: *mut u8);
44 let cnt
= rust_wasm_args_count();
45 let mut v
= Vec
::with_capacity(cnt
);
47 let n
= rust_wasm_args_arg_size(i
);
48 let mut data
= vec
![0; n
];
49 rust_wasm_args_arg_fill(i
, data
.as_mut_ptr());
50 v
.push(mem
::transmute
::<Vec
<u8>, OsString
>(data
));
54 _dont_send_or_sync_me
: PhantomData
,
60 iter
: vec
::IntoIter
<OsString
>,
61 _dont_send_or_sync_me
: PhantomData
<*mut ()>,
65 pub fn inner_debug(&self) -> &[OsString
] {
70 impl Iterator
for Args
{
72 fn next(&mut self) -> Option
<OsString
> {
75 fn size_hint(&self) -> (usize, Option
<usize>) {
80 impl ExactSizeIterator
for Args
{
81 fn len(&self) -> usize {
86 impl DoubleEndedIterator
for Args
{
87 fn next_back(&mut self) -> Option
<OsString
> {