8000 Final demo improvements by coolreader18 · Pull Request #245 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Final demo improvements #245

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 29 commits into from
Dec 29, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
03c619f
Rearrange website directory and change webpack config
coolreader18 Dec 19, 2018
4c32693
Switch to using one workspace, move profile to root Cargo.toml
coolreader18 Dec 18, 2018
ca30ebc
Genericize the wasm lib to not be specifically for the demo
coolreader18 Dec 22, 2018
2ea9dca
Add example, change some stuff in the demo to align with example
coolreader18 Dec 23, 2018
d54d2b1
Make scripts executable
coolreader18 Dec 23, 2018
840c507
Improve UX for demo
coolreader18 Dec 23, 2018
ab23f2c
Use str.format for the demo
coolreader18 Dec 23, 2018
24507de
Re-add conflicting files
coolreader18 Dec 24, 2018
ffcd40b
Remove conflicting files
coolreader18 Dec 24, 2018
< 8000 a href="/RustPython/RustPython/pull/245/commits/d1d958516d4ddf27a9ea5ca93f858d48b395a2fd" class="select-menu-item in-range" role="menuitem" data-commit="d1d958516d4ddf27a9ea5ca93f858d48b395a2fd" data-parent-commit="ffcd40b4359135491a239003f55084ce88b84fb2">
d1d9585
Change the instances of Fn(..) -> PyResult to a RustPyFunc trait alias
coolreader18 Dec 24, 2018
63b3f3e
Fix blanket impl of RustPyFunc
coolreader18 Dec 24, 2018
132930e
Allow passing closures from JS to python via `vars`
coolreader18 Dec 26, 2018
e0959b9
Implement error conversion for js_to_py
coolreader18 Dec 26, 2018
94d6a91
Fix js_to_py with JS `undefined`
coolreader18 Dec 26, 2018
c38796b
Add some documentation for functions on the demo site
coolreader18 Dec 26, 2018
877206d
Switch from shell to npm scripts for demo using webpack and @wasm-too…
coolreader18 Dec 27, 2018
2968982
Change README portion for compiling wasm
coolreader18 Dec 27, 2018
ada92d3
Add conflicting files
coolreader18 Dec 19, 2018
dfadd03
Remove (now outdated) previously conflicting files
coolreader18 Dec 27, 2018
396842e
Readd conflicting files
coolreader18 Dec 19, 2018
8303743
Remove RustPyFunc trait, just use Fn(..) everywhere
coolreader18 Dec 27, 2018
1f02cc0
Squash all demo commits onto one branch
coolreader18 Dec 28, 2018
4cc7f5a
Merge #console and #code styles
coolreader18 Dec 28, 2018
b277280
Add README and manifest fields for the WASM library
coolreader18 Dec 28, 2018
1d5df41
Add doc comments and typescript custom section
coolreader18 Dec 28, 2018
36997e1
Comment out WB's TS definitions using a hack
coolreader18 Dec 28, 2018
d7fdc5c
Fix typescript hack
coolreader18 Dec 28, 2018
e65639f
Remove yarn.lock
coolreader18 Dec 29, 2018
231e3f2
Export PyEvalOptions in typescript defs
coolreader18 Dec 29, 2018
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
Prev Previous commit
Next Next commit
Change the instances of Fn(..) -> PyResult to a RustPyFunc trait alias
  • Loading branch information
coolreader18 committed Dec 24, 2018
commit d1d958516d4ddf27a9ea5ca93f858d48b395a2fd
13 changes: 8 additions & 5 deletions vm/src/pyobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ impl PyContext {
)
}

pub fn new_rustfunc<F: 'static + Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult>(
pub fn new_rustfunc<F: 'static + RustPyFunc>(
&self,
function: F,
) -> PyObjectRef {
Expand All @@ -466,7 +466,7 @@ impl PyContext {

pub fn new_rustfunc_from_box(
&self,
function: Box<(Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult)>,
function: Box<RustPyFunc>,
) -> PyObjectRef {
PyObject::new(
PyObjectKind::RustFunction { function },
Expand All @@ -478,7 +478,7 @@ impl PyContext {
PyObject::new(PyObjectKind::Frame { frame: frame }, self.frame_type())
}

pub fn new_property<F: 'static + Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult>(
pub fn new_property<F: 'static + RustPyFunc>(
&self,
function: F,
) -> PyObjectRef {
Expand Down Expand Up @@ -523,7 +523,7 @@ impl PyContext {
)
}

pub fn new_member_descriptor<F: 'static + Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult>(
pub fn new_member_descriptor<F: 'static + RustPyFunc>(
&self,
function: F,
) -> PyObjectRef {
Expand Down Expand Up @@ -783,6 +783,9 @@ impl PyFuncArgs {
}
}

pub trait RustPyFunc: (Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult) {}
impl<T: (Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult)> for RustPyFunc {}

/// Rather than determining the type of a python object, this enum is more
/// a holder for the rust payload of a python object. It is more a carrier
/// of rust data for a particular python object. Determine the python type
Expand Down Expand Up @@ -859,7 +862,7 @@ pub enum PyObjectKind {
dict: PyObjectRef,
},
RustFunction {
function: Box<(Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult)>,
function: Box<RustPyFunc>,
},
}

Expand Down
2 changes: 1 addition & 1 deletion wasm/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn eval_py(source: &str, options: Option<Object>) -> Result<JsValue, JsValue
};
let mut vm = VirtualMachine::new();

let print_fn: Box<(Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult)> = match stdout {
let print_fn: Box<pyobject::RustPyFunc> = match stdout {
Some(val) => {
if let Some(selector) = val.as_string() {
Box::new(
Expand Down
0