libhv_bindings.cpp 571 B

1234567891011121314151617181920
  1. #include "libhv_bindings.hpp"
  2. #include "base/herr.h"
  3. extern "C" void pk__add_module_libhv() {
  4. py_GlobalRef mod = py_newmodule("libhv");
  5. libhv_register_HttpRequest(mod);
  6. libhv_register_HttpClient(mod);
  7. libhv_register_HttpServer(mod);
  8. libhv_register_WebSocketClient(mod);
  9. py_bindfunc(mod, "strerror", [](int argc, py_Ref argv) {
  10. PY_CHECK_ARGC(1);
  11. PY_CHECK_ARG_TYPE(0, tp_int);
  12. int code = py_toint(py_arg(0));
  13. const char* msg = hv_strerror(code);
  14. py_newstr(py_retval(), msg);
  15. return true;
  16. });
  17. }