test.cpp 683 B

1234567891011121314151617181920212223242526272829
  1. #define PK_SHARED_MODULE
  2. #include "pocketpy.h"
  3. using namespace pkpy;
  4. extern "C" {
  5. PK_EXPORT
  6. PyObject* platform_module__init__(VM* vm, const char* version){
  7. PyObject* mod = vm->new_module("test");
  8. vm->_stdout(vm, "Hello from dylib!\n");
  9. vm->bind(mod, "hello()", [](VM* vm, ArgsView args){
  10. vm->_stdout(vm, "Hello from dylib!\n");
  11. return vm->None;
  12. });
  13. return mod;
  14. }
  15. #if _WIN32
  16. BOOL WINAPI DllMain(
  17. HINSTANCE hinstDLL, // handle to DLL module
  18. DWORD fdwReason, // reason for calling function
  19. LPVOID lpvReserved ) // reserved
  20. {
  21. return TRUE; // Successful DLL_PROCESS_ATTACH.
  22. }
  23. #endif
  24. }