From db2492829bfc6cd6af6516083a9cbee5dcdd8975 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 4 May 2023 16:44:45 +0800 Subject: [PATCH] ... --- docs/C-API/vm.md | 12 ++---------- docs/quick-start/installation.md | 6 ++---- web/index.js | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/docs/C-API/vm.md b/docs/C-API/vm.md index bf08c691..89a6fb37 100644 --- a/docs/C-API/vm.md +++ b/docs/C-API/vm.md @@ -3,7 +3,7 @@ title: VM icon: dot order: 10 --- -#### `VM* pkpy_new_vm(bool use_stdio)` +#### `VM* pkpy_new_vm()` Create a virtual machine. @@ -27,12 +27,4 @@ Run a given source on a virtual machine. Get a global variable of a virtual machine. Return `__repr__` of the result. -If the variable is not found, return `nullptr`. - -#### `char* pkpy_vm_read_output(VM* vm)` - -Read the standard output and standard error as string of a virtual machine. -The `vm->use_stdio` should be `false`. -After this operation, both stream will be cleared. - -Return a json representing the result. \ No newline at end of file +If the variable is not found, return `nullptr`. \ No newline at end of file diff --git a/docs/quick-start/installation.md b/docs/quick-start/installation.md index 48cc4ba2..f58780e3 100644 --- a/docs/quick-start/installation.md +++ b/docs/quick-start/installation.md @@ -56,14 +56,12 @@ You need to use the C++ `new` operator to create a `VM` instance. VM* vm = new VM(); ``` -The constructor can take 2 extra parameters. +The constructor can take 1 extra parameters. -#### `VM(bool use_stdio=true, bool enable_os=true)` +#### `VM(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`. - When you are done with the `VM` instance, you need to use the C++ `delete` operator to free the memory. ```cpp diff --git a/web/index.js b/web/index.js index 8fd21e2c..2621b788 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', ['boolean', 'boolean'], [true, true]); + var vm = Module.ccall('pkpy_new_vm', 'number', ['boolean'], [true]); repl = Module.ccall('pkpy_new_repl', 'number', ['number'], [vm]); term.write(need_more_lines ? "... " : ">>> "); },