mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
add py_resetvm
This commit is contained in:
parent
a11d3276f9
commit
e96eb43c6b
@ -90,6 +90,8 @@ PK_EXPORT int py_currentvm();
|
|||||||
/// Switch to a VM.
|
/// Switch to a VM.
|
||||||
/// @param index index of the VM ranging from 0 to 16 (exclusive). `0` is the default VM.
|
/// @param index index of the VM ranging from 0 to 16 (exclusive). `0` is the default VM.
|
||||||
PK_EXPORT void py_switchvm(int index);
|
PK_EXPORT void py_switchvm(int index);
|
||||||
|
/// Reset a VM.
|
||||||
|
PK_EXPORT void py_resetvm(int index);
|
||||||
/// Set `sys.argv`. Used for storing command-line arguments.
|
/// Set `sys.argv`. Used for storing command-line arguments.
|
||||||
PK_EXPORT void py_sys_setargv(int argc, char** argv);
|
PK_EXPORT void py_sys_setargv(int argc, char** argv);
|
||||||
/// Setup the callbacks for the current VM.
|
/// Setup the callbacks for the current VM.
|
||||||
|
@ -61,6 +61,14 @@ void py_switchvm(int index) {
|
|||||||
pk_current_vm = pk_all_vm[index];
|
pk_current_vm = pk_all_vm[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void py_resetvm(int index){
|
||||||
|
if(index < 0 || index >= 16) c11__abort("invalid vm index");
|
||||||
|
VM* vm = pk_all_vm[index];
|
||||||
|
if(!vm) c11__abort("vm not initialized");
|
||||||
|
VM__dtor(vm);
|
||||||
|
VM__ctor(vm);
|
||||||
|
}
|
||||||
|
|
||||||
int py_currentvm() {
|
int py_currentvm() {
|
||||||
for(int i = 0; i < 16; i++) {
|
for(int i = 0; i < 16; i++) {
|
||||||
if(pk_all_vm[i] == pk_current_vm) return i;
|
if(pk_all_vm[i] == pk_current_vm) return i;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user