quickjs-libc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 <stdio.h>
  27. #include <stdlib.h>
  28. #include "quickjs.h"
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. JSModuleDef *js_init_module_std(JSContext *ctx, const char *module_name);
  33. JSModuleDef *js_init_module_os(JSContext *ctx, const char *module_name);
  34. void js_std_add_helpers(JSContext *ctx, int argc, char **argv);
  35. void js_std_loop(JSContext *ctx);
  36. JSValue js_std_await(JSContext *ctx, JSValue obj);
  37. void js_std_init_handlers(JSRuntime *rt);
  38. void js_std_free_handlers(JSRuntime *rt);
  39. void js_std_dump_error(JSContext *ctx);
  40. uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename);
  41. int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val,
  42. JS_BOOL use_realpath, JS_BOOL is_main);
  43. int js_module_test_json(JSContext *ctx, JSValueConst attributes);
  44. int js_module_check_attributes(JSContext *ctx, void *opaque, JSValueConst attributes);
  45. JSModuleDef *js_module_loader(JSContext *ctx,
  46. const char *module_name, void *opaque,
  47. JSValueConst attributes);
  48. void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len,
  49. int flags);
  50. void js_std_eval_binary_json_module(JSContext *ctx,
  51. const uint8_t *buf, size_t buf_len,
  52. const char *module_name);
  53. void js_std_promise_rejection_tracker(JSContext *ctx, JSValueConst promise,
  54. JSValueConst reason,
  55. JS_BOOL is_handled, void *opaque);
  56. void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt));
  57. #ifdef __cplusplus
  58. } /* extern "C" { */
  59. #endif
  60. #endif /* QUICKJS_LIBC_H */