3 ms·
Here is what I came up with for calling a c function after poking around a little bit: #include "pocketpy.h" // builtin function that can be called
by benob 4y ago
Here is what I came up with for calling a c function after poking around a little bit:
#include "pocketpy.h"
// builtin function that can be called
PyVar test(VM* vm, const pkpy::Args& args) {
printf("called!\n");
return vm->PyStr("hi there");
}
int main(){
// Create a virtual machine
VM* vm = pkpy_new_vm(true);
vm->bind_builtin_func<1>("test", test);
// Hello world!
pkpy_vm_exec(vm, "print(test('Hello world!'))");
// Free the resources
pkpy_delete(vm);
return 0;
}