This commit is contained in:
BLUELOVETH 2023-05-29 22:46:51 +08:00
parent f76c4e69d6
commit 239fd7e18b
4 changed files with 15 additions and 5 deletions

View File

@ -4,10 +4,6 @@ icon: dot
order: 10 order: 10
--- ---
!!!
Lua Style C-API cannot be mixed with Legacy C-API.
!!!
#### `VM* pkpy_new_vm()` #### `VM* pkpy_new_vm()`
Create a virtual machine. Create a virtual machine.
@ -20,6 +16,10 @@ Add a source module into a virtual machine.
Run a given source on a virtual machine. Run a given source on a virtual machine.
#### `void pkpy_vm_exec_2(pkpy::VM* vm, const char* source, const char* filename, int mode, const char* module)`
Advanced version of `pkpy_vm_exec`.
#### `void pkpy_delete(void* p)` #### `void pkpy_delete(void* p)`
Delete a pointer allocated by `pkpy_xxx_xxx`. Delete a pointer allocated by `pkpy_xxx_xxx`.

View File

@ -15,3 +15,6 @@ order: 5
Return true if the vm is currently in an error state. Return true if the vm is currently in an error state.
#### `bool pkpy_error(pkpy_vm*, const char* name, const char* message)`
Set the error state of the vm. It is almost equivalent to `raise` in python.

View File

@ -14,7 +14,7 @@ Stack index is 0-based instead of 1-based.
Pop `n` items from the stack. Pop `n` items from the stack.
#### `bool pkpy_push_function(pkpy_vm*, pkpy_function)` #### `bool pkpy_push_function(pkpy_vm*, pkpy_function, int argc)`
Push a function onto the stack. The function is of `typedef int (*pkpy_function)(pkpy_vm*);` Push a function onto the stack. The function is of `typedef int (*pkpy_function)(pkpy_vm*);`

View File

@ -17,3 +17,10 @@ Set the global variable to the value at the top of the stack.
Get the global variable and push it to the top of the stack. Get the global variable and push it to the top of the stack.
#### `bool pkpy_getattr(pkpy_vm*, const char* name)`
A wrapper of `OP_LOAD_ATTR` bytecode.
#### `bool pkpy_setattr(pkpy_vm*, const char* name)`
A wrapper of `OP_STORE_ATTR` bytecode.