This commit is contained in:
blueloveTH 2024-06-15 14:20:21 +08:00
parent 3bd794f2fb
commit 597abacc58
3 changed files with 0 additions and 18 deletions

View File

@ -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.

View File

@ -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

View File

@ -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,