From dfadd03f9556e5de899dc03df64ec4f1916c34da Mon Sep 17 00:00:00 2001 From: coolreader18 <33094578+coolreader18@users.noreply.github.com> Date: Thu, 27 Dec 2018 00:02:33 -0600 Subject: [PATCH] Remove (now outdated) previously conflicting files --- wasm/app/index.html | 89 --------------------------- wasm/app/index.js | 27 --------- wasm/src/lib.rs | 143 -------------------------------------------- 3 files changed, 259 deletions(-) delete mode 100644 wasm/app/index.html delete mode 100644 wasm/app/index.js delete mode 100644 wasm/src/lib.rs diff --git a/wasm/app/index.html b/wasm/app/index.html deleted file mode 100644 index f46ce1251..000000000 --- a/wasm/app/index.html +++ /dev/null @@ -1,89 +0,0 @@ - - -
- -- RustPython is a Python interpreter writter in Rust. This demo is - compiled from Rust to WebAssembly so it runs in the browser -
-Please input your python code below and click Run:
-
- Alternatively, open up your browser's devtools and play with
- rp.eval_py('print("a")')
-
Here's some info regarding the rp.eval_py() function
json.dumps.
- js_vars. Again, only values that can be serialized
- with JSON.stringify() will go through.
-
-
-
diff --git a/wasm/app/index.js b/wasm/app/index.js
deleted file mode 100644
index d21ac7a04..000000000
--- a/wasm/app/index.js
+++ /dev/null
@@ -1,27 +0,0 @@
-import * as rp from 'rustpython_wasm';
-
-// so people can play around with it
-window.rp = rp;
-
-function runCodeFromTextarea(_) {
- const consoleElement = document.getElementById('console');
- const errorElement = document.getElementById('error');
-
- // Clean the console and errors
- consoleElement.value = '';
- errorElement.textContent = '';
-
- const code = document.getElementById('code').value;
- try {
- rp.run_from_textbox(code);
- } catch (e) {
- errorElement.textContent = e;
- console.error(e);
- }
-}
-
-document
- .getElementById('run-btn')
- .addEventListener('click', runCodeFromTextarea);
-
-runCodeFromTextarea(); // Run once for demo
diff --git a/wasm/src/lib.rs b/wasm/src/lib.rs
deleted file mode 100644
index 9ac5677d7..000000000
--- a/wasm/src/lib.rs
+++ /dev/null
@@ -1,143 +0,0 @@
-mod wasm_builtins;
-
-extern crate js_sys;
-extern crate rustpython_vm;
-extern crate wasm_bindgen;
-extern crate web_sys;
-
-use rustpython_vm::compile;
-use rustpython_vm::pyobject::{self, PyObjectRef, PyResult};
-use rustpython_vm::VirtualMachine;
-use wasm_bindgen::prelude::*;
-use web_sys::console;
-
-fn py_str_err(vm: &mut VirtualMachine, py_err: &PyObjectRef) -> String {
- vm.to_pystr(&py_err)
- .unwrap_or_else(|_| "Error, and error getting error message".into())
-}
-
-fn py_to_js(vm: &mut VirtualMachine, py_obj: PyObjectRef) -> JsValue {
- let dumps = rustpython_vm::import::import(
- vm,
- std::path::PathBuf::default(),
- "json",
- &Some("dumps".into()),
- )
- .expect("Couldn't get json.dumps function");
- match vm.invoke(dumps, pyobject::PyFuncArgs::new(vec![py_obj], vec![])) {
- Ok(value) => {
- let json = vm.to_pystr(&value).unwrap();
- js_sys::JSON::parse(&json).unwrap_or(JsValue::UNDEFINED)
- }
- Err(_) => JsValue::UNDEFINED,
- }
-}
-
-fn js_to_py(vm: &mut VirtualMachine, js_val: JsValue) -> PyObjectRef {
- let json = match js_sys::JSON::stringify(&js_val) {
- Ok(json) => String::from(json),
- Err(_) => return vm.get_none(),
- };
-
- let loads = rustpython_vm::import::import(
- vm,
- std::path::PathBuf::default(),
- "json",
- &Some("loads".into()),
- )
- .expect("Couldn't get json.loads function");
-
- let py_json = vm.new_str(json);
-
- vm.invoke(loads, pyobject::PyFuncArgs::new(vec![py_json], vec![]))
- // can safely unwrap because we know it's valid JSON
- .unwrap()
-}
-
-fn eval