test.c 564 B

123456789101112131415161718192021222324
  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* platform_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. if(pkpy_check_error(vm)){
  15. char* err;
  16. pkpy_clear_error(vm, &err);
  17. printf("%s\n", err);
  18. free(err);
  19. exit(1);
  20. }
  21. return "test";
  22. }