From 4e74d66768e8aa996b83af4cf4750c4b14a8e8e6 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 24 Apr 2023 17:47:08 +0800 Subject: [PATCH] ... ... --- docs/quick-start/overview.md | 10 +++++++++- docs/retype.yml | 2 +- web/index.js | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/quick-start/overview.md b/docs/quick-start/overview.md index bbe9bb82..d95653d1 100644 --- a/docs/quick-start/overview.md +++ b/docs/quick-start/overview.md @@ -13,4 +13,12 @@ You need to use the C++ `new` operator to create a `VM` instance. ```cpp VM* vm = new VM(); -``` \ No newline at end of file +``` + +The constructor can take 2 extra parameters. + +#### `VM(bool use_stdio=true, bool enable_os=true)` + ++ `use_stdio`, if `true`, the `print()` function outputs string to `stdout`. Error messages will be send to `stderr`; If `false`, they will be sent to an internal buffer. In the latter case, you need to read them via `read_output` manually. ++ `enable_os`, whether to enable OS-related features or not. This setting controls the availability of some priviledged modules such os `io` and `os` as well as builtin function `open`. + diff --git a/docs/retype.yml b/docs/retype.yml index 1d6276f6..52b05c50 100644 --- a/docs/retype.yml +++ b/docs/retype.yml @@ -14,7 +14,7 @@ links: link: "" - text: "Live Demo" icon: play - link: "./static/web/index.html" + link: "https://pocketpy.dev/static/web/" target: blank - text: "Github" icon: mark-github diff --git a/web/index.js b/web/index.js index 27029a0a..8fd21e2c 100644 --- a/web/index.js +++ b/web/index.js @@ -113,7 +113,7 @@ var Module = { term.write(text + "\r\n"); }, 'onRuntimeInitialized': function(text) { - var vm = Module.ccall('pkpy_new_vm', 'number', [], []); + var vm = Module.ccall('pkpy_new_vm', 'number', ['boolean', 'boolean'], [true, true]); repl = Module.ccall('pkpy_new_repl', 'number', ['number'], [vm]); term.write(need_more_lines ? "... " : ">>> "); },