forked from bytecodealliance/StarlingMonkey
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript_loader.h
More file actions
36 lines (30 loc) · 1.33 KB
/
script_loader.h
File metadata and controls
36 lines (30 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef SCRIPTLOADER_H
#define SCRIPTLOADER_H
#include <extension-api.h>
// TODO: remove these once the warnings are fixed
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"
#include <js/CompileOptions.h>
#include <js/Modules.h>
#include <js/SourceText.h>
#pragma clang diagnostic pop
class ScriptLoader {
public:
ScriptLoader(api::Engine* engine, JS::CompileOptions* opts);
~ScriptLoader();
bool define_builtin_module(const char* id, HandleValue builtin);
void enable_module_mode(bool enable);
bool eval_top_level_script(const char *path, JS::SourceText<mozilla::Utf8Unit> &source,
MutableHandleValue result, MutableHandleValue tla_promise);
bool load_script(JSContext* cx, const char *script_path, JS::SourceText<mozilla::Utf8Unit> &script);
/**
* Load a script without attempting to resolve its path relative to a base path.
*
* This is useful for loading ancillary scripts without interfering with, or depending on,
* the script loader's state as determined by loading and running content scripts.
*/
bool load_resolved_script(JSContext *cx, const char *specifier, const char *resolved_path,
JS::SourceText<mozilla::Utf8Unit> &script);
};
#endif //SCRIPTLOADER_H