Skip to content

Commit 9d9f4ae

Browse files
committed
chore: clang format ModuleInternal files
1 parent 55c5c51 commit 9d9f4ae

File tree

2 files changed

+477
-425
lines changed

2 files changed

+477
-425
lines changed

NativeScript/runtime/ModuleInternal.h

Lines changed: 68 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,75 @@
77
namespace tns {
88

99
class ModuleInternal {
10-
public:
11-
ModuleInternal(v8::Local<v8::Context> context);
12-
bool RunModule(v8::Isolate* isolate, std::string path);
13-
void RunScript(v8::Isolate* isolate, std::string script);
14-
15-
private:
16-
static void RequireCallback(const v8::FunctionCallbackInfo<v8::Value>& info);
17-
v8::Local<v8::Function> GetRequireFunction(v8::Isolate* isolate, const std::string& dirName);
18-
v8::Local<v8::Object> LoadImpl(v8::Isolate* isolate, const std::string& moduleName, const std::string& baseDir, bool& isData);
19-
v8::Local<v8::Script> LoadScript(v8::Isolate* isolate, const std::string& path);
20-
v8::Local<v8::String> WrapModuleContent(v8::Isolate* isolate, const std::string& path);
21-
v8::Local<v8::Object> LoadModule(v8::Isolate* isolate, const std::string& modulePath, const std::string& cacheKey);
22-
v8::Local<v8::Object> LoadData(v8::Isolate* isolate, const std::string& modulePath);
23-
std::string ResolvePath(v8::Isolate* isolate, const std::string& baseDir, const std::string& moduleName);
24-
std::string ResolvePathFromPackageJson(const std::string& packageJson, bool& error);
25-
v8::ScriptCompiler::CachedData* LoadScriptCache(const std::string& path);
26-
void SaveScriptCache(const v8::Local<v8::Script> script, const std::string& path);
27-
std::string GetCacheFileName(const std::string& path);
28-
v8::MaybeLocal<v8::Value> RunScriptString(v8::Isolate* isolate, v8::Local<v8::Context> context, const std::string script);
29-
30-
31-
std::unique_ptr<v8::Persistent<v8::Function>> requireFunction_;
32-
std::unique_ptr<v8::Persistent<v8::Function>> requireFactoryFunction_;
33-
robin_hood::unordered_map<std::string, std::shared_ptr<v8::Persistent<v8::Object>>> loadedModules_;
34-
35-
struct TempModule {
36-
public:
37-
TempModule(ModuleInternal* module, std::string modulePath, std::string cacheKey, std::shared_ptr<v8::Persistent<v8::Object>> poModuleObj)
38-
: module_(module), dispose_(true), modulePath_(modulePath), cacheKey_(cacheKey) {
39-
module->loadedModules_.emplace(modulePath, poModuleObj);
40-
module->loadedModules_.emplace(cacheKey, poModuleObj);
41-
}
42-
43-
~TempModule() {
44-
if (this->dispose_) {
45-
this->module_->loadedModules_.erase(modulePath_);
46-
this->module_->loadedModules_.erase(cacheKey_);
47-
}
48-
}
49-
50-
void SaveToCache() {
51-
this->dispose_ = false;
52-
}
53-
private:
54-
ModuleInternal* module_;
55-
bool dispose_;
56-
std::string modulePath_;
57-
std::string cacheKey_;
58-
};
10+
public:
11+
ModuleInternal(v8::Local<v8::Context> context);
12+
bool RunModule(v8::Isolate* isolate, std::string path);
13+
void RunScript(v8::Isolate* isolate, std::string script);
14+
15+
private:
16+
static void RequireCallback(const v8::FunctionCallbackInfo<v8::Value>& info);
17+
v8::Local<v8::Function> GetRequireFunction(v8::Isolate* isolate,
18+
const std::string& dirName);
19+
v8::Local<v8::Object> LoadImpl(v8::Isolate* isolate,
20+
const std::string& moduleName,
21+
const std::string& baseDir, bool& isData);
22+
v8::Local<v8::Script> LoadScript(v8::Isolate* isolate,
23+
const std::string& path);
24+
v8::Local<v8::String> WrapModuleContent(v8::Isolate* isolate,
25+
const std::string& path);
26+
v8::Local<v8::Object> LoadModule(v8::Isolate* isolate,
27+
const std::string& modulePath,
28+
const std::string& cacheKey);
29+
v8::Local<v8::Object> LoadData(v8::Isolate* isolate,
30+
const std::string& modulePath);
31+
std::string ResolvePath(v8::Isolate* isolate, const std::string& baseDir,
32+
const std::string& moduleName);
33+
std::string ResolvePathFromPackageJson(const std::string& packageJson,
34+
bool& error);
35+
v8::ScriptCompiler::CachedData* LoadScriptCache(const std::string& path);
36+
void SaveScriptCache(const v8::Local<v8::Script> script,
37+
const std::string& path);
38+
std::string GetCacheFileName(const std::string& path);
39+
v8::MaybeLocal<v8::Value> RunScriptString(v8::Isolate* isolate,
40+
v8::Local<v8::Context> context,
41+
const std::string script);
42+
43+
std::unique_ptr<v8::Persistent<v8::Function>> requireFunction_;
44+
std::unique_ptr<v8::Persistent<v8::Function>> requireFactoryFunction_;
45+
robin_hood::unordered_map<std::string,
46+
std::shared_ptr<v8::Persistent<v8::Object>>>
47+
loadedModules_;
48+
49+
struct TempModule {
50+
public:
51+
TempModule(ModuleInternal* module, std::string modulePath,
52+
std::string cacheKey,
53+
std::shared_ptr<v8::Persistent<v8::Object>> poModuleObj)
54+
: module_(module),
55+
dispose_(true),
56+
modulePath_(modulePath),
57+
cacheKey_(cacheKey) {
58+
module->loadedModules_.emplace(modulePath, poModuleObj);
59+
module->loadedModules_.emplace(cacheKey, poModuleObj);
60+
}
61+
62+
~TempModule() {
63+
if (this->dispose_) {
64+
this->module_->loadedModules_.erase(modulePath_);
65+
this->module_->loadedModules_.erase(cacheKey_);
66+
}
67+
}
68+
69+
void SaveToCache() { this->dispose_ = false; }
70+
71+
private:
72+
ModuleInternal* module_;
73+
bool dispose_;
74+
std::string modulePath_;
75+
std::string cacheKey_;
76+
};
5977
};
6078

61-
}
79+
} // namespace tns
6280

6381
#endif /* ModuleInternal_h */

0 commit comments

Comments
 (0)