@@ -45,10 +45,6 @@ pub fn setup_console_error() {
45
45
std:: panic:: set_hook ( Box :: new ( panic_hook) ) ;
46
46
}
47
47
48
- // Hack to comment out wasm-bindgen's generated typescript definitons
49
- #[ wasm_bindgen( typescript_custom_section) ]
50
- const TS_CMT_START : & ' static str = "/*" ;
51
-
52
48
fn run_py ( source : & str , options : Option < Object > , mode : Mode ) -> Result < JsValue , JsValue > {
53
49
let vm = VMStore :: init ( PY_EVAL_VM_ID . into ( ) , Some ( true ) ) ;
54
50
let options = options. unwrap_or_else ( Object :: new) ;
@@ -70,7 +66,7 @@ fn run_py(source: &str, options: Option<Object>, mode: Mode) -> Result<JsValue,
70
66
}
71
67
vm. run ( source, mode)
72
68
}
73
- # [ wasm_bindgen ( js_name = pyEval ) ]
69
+
74
70
/// Evaluate Python code
75
71
///
76
72
/// ```js
@@ -87,12 +83,11 @@ fn run_py(source: &str, options: Option<Object>, mode: Mode) -> Result<JsValue,
87
83
/// - `stdout?`: `"console" | ((out: string) => void) | null`: A function to replace the
88
84
/// native print native print function, and it will be `console.log` when giving
89
85
/// `undefined` or "console", and it will be a dumb function when giving null.
90
-
86
+ # [ wasm_bindgen ( js_name = pyEval ) ]
91
87
pub fn eval_py ( source : & str , options : Option < Object > ) -> Result < JsValue , JsValue > {
92
88
run_py ( source, options, Mode :: Eval )
93
89
}
94
90
95
- #[ wasm_bindgen( js_name = pyExec) ]
96
91
/// Evaluate Python code
97
92
///
98
93
/// ```js
@@ -102,11 +97,11 @@ pub fn eval_py(source: &str, options: Option<Object>) -> Result<JsValue, JsValue
102
97
/// `code`: `string`: The Python code to run in exec mode
103
98
///
104
99
/// `options`: The options are the same as eval mode
105
- pub fn exec_py ( source : & str , options : Option < Object > ) {
106
- let _ = run_py ( source, options, Mode :: Exec ) ;
100
+ #[ wasm_bindgen( js_name = pyExec) ]
101
+ pub fn exec_py ( source : & str , options : Option < Object > ) -> Result < ( ) , JsValue > {
102
+ run_py ( source, options, Mode :: Exec ) . map ( drop)
107
103
}
108
104
109
- #[ wasm_bindgen( js_name = pyExecSingle) ]
110
105
/// Evaluate Python code
111
106
///
112
107
/// ```js
@@ -116,17 +111,7 @@ pub fn exec_py(source: &str, options: Option<Object>) {
116
111
/// `code`: `string`: The Python code to run in exec single mode
117
112
///
118
113
/// `options`: The options are the same as eval mode
114
+ #[ wasm_bindgen( js_name = pyExecSingle) ]
119
115
pub fn exec_single_py ( source : & str , options : Option < Object > ) -> Result < JsValue , JsValue > {
120
116
run_py ( source, options, Mode :: Single )
121
117
}
122
-
123
- #[ wasm_bindgen( typescript_custom_section) ]
124
- const TYPESCRIPT_DEFS : & ' static str = r#"
125
- */
126
- export interface PyEvalOptions {
127
- stdout: (out: string) => void;
128
- vars: { [key: string]: any };
129
- }
130
-
131
- export function pyEval(code: string, options?: PyEvalOptions): any;
132
- "# ;
0 commit comments