test.c 490 B

12345678910111213141516171819
  1. #include "pocketpy_c.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. static int hello(pkpy_vm* vm){
  5. printf("Hello from dylib!\n");
  6. return 0;
  7. }
  8. PK_EXPORT
  9. const char* pkpy_module__init__(pkpy_vm* vm, const char* version){
  10. printf("version: %s\n", version);
  11. pkpy_push_function(vm, "hello()", hello);
  12. pkpy_push_module(vm, "test");
  13. pkpy_setattr(vm, pkpy_name("hello"));
  14. // check if initialization failed
  15. if(pkpy_clear_error(vm, NULL)) return NULL;
  16. return "test";
  17. }