mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
some fix
This commit is contained in:
parent
3bd794f2fb
commit
597abacc58
@ -92,13 +92,6 @@ vm->bind(obj, "f() -> int", [](VM* vm, ArgsView args){
|
|||||||
}, x); // capture x
|
}, x); // capture x
|
||||||
```
|
```
|
||||||
|
|
||||||
The 3rd way is to change the macro `PK_ENABLE_STD_FUNCTION` in `config.h`:
|
|
||||||
```cpp
|
|
||||||
#define PK_ENABLE_STD_FUNCTION 0 // => 1
|
|
||||||
```
|
|
||||||
|
|
||||||
Then you can use standard capture list in lambda.
|
|
||||||
|
|
||||||
## Bind a class or struct
|
## Bind a class or struct
|
||||||
|
|
||||||
Assume you have a struct `Point` declared as follows.
|
Assume you have a struct `Point` declared as follows.
|
||||||
|
@ -24,13 +24,6 @@
|
|||||||
#define PK_GC_MIN_THRESHOLD 16384
|
#define PK_GC_MIN_THRESHOLD 16384
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Whether to use `pkpy::function<>` to do bindings or not
|
|
||||||
// By default, functions to be binded must be a C function pointer without capture
|
|
||||||
// However, someone thinks it's not convenient.
|
|
||||||
// By setting this to 1, capturing lambdas can be binded,
|
|
||||||
// but it's slower and may cause "code bloat", it also needs more time to compile.
|
|
||||||
#define PK_ENABLE_STD_FUNCTION 0
|
|
||||||
|
|
||||||
/*************** debug settings ***************/
|
/*************** debug settings ***************/
|
||||||
// Do not edit the following settings unless you know what you are doing
|
// Do not edit the following settings unless you know what you are doing
|
||||||
#define PK_DEBUG_CEVAL_STEP 0
|
#define PK_DEBUG_CEVAL_STEP 0
|
||||||
|
@ -7,11 +7,7 @@
|
|||||||
|
|
||||||
namespace pkpy {
|
namespace pkpy {
|
||||||
|
|
||||||
#if PK_ENABLE_STD_FUNCTION
|
|
||||||
using NativeFuncC = function<PyVar(VM*, ArgsView)>;
|
|
||||||
#else
|
|
||||||
typedef PyVar (*NativeFuncC)(VM*, ArgsView);
|
typedef PyVar (*NativeFuncC)(VM*, ArgsView);
|
||||||
#endif
|
|
||||||
|
|
||||||
enum class BindType {
|
enum class BindType {
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user