mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 12:30:19 +00:00
...
This commit is contained in:
parent
7261d12034
commit
68036f8731
@ -6,10 +6,14 @@ order: 6
|
|||||||
|
|
||||||
### `bool pkpy_vectorcall(pkpy_vm*, int argc)`
|
### `bool pkpy_vectorcall(pkpy_vm*, int argc)`
|
||||||
|
|
||||||
Wraps `vm->vectorcall(argc)`.
|
Wraps `vm->vectorcall(argc)`. This function is used to call a function with a fixed number of arguments. The arguments are popped from the stack. The return value is pushed onto the stack.
|
||||||
|
|
||||||
This is the only way to call a function in the C-APIs.
|
|
||||||
|
|
||||||
1. First push the function to call.
|
1. First push the function to call.
|
||||||
2. Push `self` argument if it is a method call. Otherwise, call `pkpy_push_null`.
|
2. Push `self` argument if it is a method call. Otherwise, call `pkpy_push_null`.
|
||||||
3. Push arguments from left to right.
|
3. Push arguments from left to right.
|
||||||
|
|
||||||
|
!!!
|
||||||
|
Unlike lua, a python function always returns a value.
|
||||||
|
If the function returns `void`, it will push `None` onto the stack.
|
||||||
|
You can call `pkpy_pop_top` to discard the return value.
|
||||||
|
!!!
|
@ -103,14 +103,26 @@ PK_EXPORT bool pkpy_is_none(pkpy_vm*, int i);
|
|||||||
|
|
||||||
Push a global variable onto the stack.
|
Push a global variable onto the stack.
|
||||||
|
|
||||||
|
```
|
||||||
|
[] -> [value]
|
||||||
|
```
|
||||||
|
|
||||||
+ `bool pkpy_setglobal(pkpy_vm*, pkpy_CName name)`
|
+ `bool pkpy_setglobal(pkpy_vm*, pkpy_CName name)`
|
||||||
|
|
||||||
Set a global variable to the value at the top of the stack.
|
Set a global variable to the value at the top of the stack.
|
||||||
|
|
||||||
|
```
|
||||||
|
[value] -> []
|
||||||
|
```
|
||||||
|
|
||||||
+ `bool pkpy_eval(pkpy_vm*, const char* source)`
|
+ `bool pkpy_eval(pkpy_vm*, const char* source)`
|
||||||
|
|
||||||
Evaluate a string and push the result onto the stack.
|
Evaluate a string and push the result onto the stack.
|
||||||
|
|
||||||
|
```
|
||||||
|
[] -> [result]
|
||||||
|
```
|
||||||
|
|
||||||
+ `bool pkpy_unpack_sequence(pkpy_vm*, int size)`
|
+ `bool pkpy_unpack_sequence(pkpy_vm*, int size)`
|
||||||
|
|
||||||
Unpack a sequence at the top of the stack. `size` is the element count of the sequence.
|
Unpack a sequence at the top of the stack. `size` is the element count of the sequence.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user