-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathjsb_amd_module_loader.h
More file actions
38 lines (31 loc) · 1.23 KB
/
jsb_amd_module_loader.h
File metadata and controls
38 lines (31 loc) · 1.23 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
37
38
#ifndef GODOTJS_AMD_MODULE_LOADER_H
#define GODOTJS_AMD_MODULE_LOADER_H
#include "jsb_bridge_pch.h"
#include "jsb_module_loader.h"
#include "../internal/jsb_preset_source.h"
namespace jsb
{
// `AMDModuleLoader` follows the fundamental guidelines of the `AsynchronousModuleDefinition`, but not really async.
// it's currently only used to load the `compiled` editor script bundle.
class AMDModuleLoader : public IModuleLoader
{
private:
Vector<String> deps_;
v8::Global<v8::Function> evaluator_;
bool internal_;
public:
AMDModuleLoader(const Vector<String>& p_deps, v8::Global<v8::Function>&& p_evaluator)
: deps_(p_deps), evaluator_(std::move(p_evaluator))
{
}
virtual ~AMDModuleLoader() override { evaluator_.Reset(); }
virtual bool load(Environment* p_env, JavaScriptModule& p_module) override;
void set_internal(bool internal)
{
internal_ = internal;
}
static Error load_source(Environment* p_env, const internal::PresetSource& p_source);
static void load_source(Environment* p_env, const char* p_source, int p_len, const String& p_name, bool p_internal = false);
};
} // namespace jsb
#endif