quickjs-libc.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * QuickJS C library
  3. *
  4. * Copyright (c) 2017-2018 Fabrice Bellard
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. #ifndef QUICKJS_LIBC_H
  25. #define QUICKJS_LIBC_H
  26. #include <stdbool.h>
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include "quickjs.h"
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. JSModuleDef *js_init_module_std(JSContext *ctx, const char *module_name);
  34. JSModuleDef *js_init_module_os(JSContext *ctx, const char *module_name);
  35. JSModuleDef *js_init_module_bjson(JSContext *ctx, const char *module_name);
  36. void js_std_add_helpers(JSContext *ctx, int argc, char **argv);
  37. int js_std_loop(JSContext *ctx);
  38. JSValue js_std_await(JSContext *ctx, JSValue obj);
  39. void js_std_init_handlers(JSRuntime *rt);
  40. void js_std_free_handlers(JSRuntime *rt);
  41. void js_std_dump_error(JSContext *ctx);
  42. uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename);
  43. int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val,
  44. bool use_realpath, bool is_main);
  45. JSModuleDef *js_module_loader(JSContext *ctx,
  46. const char *module_name, void *opaque);
  47. void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len,
  48. int flags);
  49. void js_std_promise_rejection_tracker(JSContext *ctx, JSValueConst promise,
  50. JSValueConst reason,
  51. bool is_handled, void *opaque);
  52. void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt));
  53. #ifdef __cplusplus
  54. } /* extern "C" { */
  55. #endif
  56. #endif /* QUICKJS_LIBC_H */