-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathqdiriterator_wrapper.h
More file actions
109 lines (96 loc) · 3.55 KB
/
Copy pathqdiriterator_wrapper.h
File metadata and controls
109 lines (96 loc) · 3.55 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#pragma once
namespace shelllet {
namespace core {
template<typename T, typename U, bool C>
class QDirIteratorWrapper : public ObjectWrapper<T, U, C>
{
public:
template <bool M>
QDirIteratorWrapper(QDirIteratorPrivate<T, M>& d, const v8::FunctionCallbackInfo<v8::Value>& args)
: ObjectWrapper(d, args) {
}
QDirIteratorWrapper(v8::Isolate* isolate, const v8::Local<v8::FunctionTemplate>& tpl) : ObjectWrapper(isolate, tpl)
{
}
QDirIteratorWrapper(v8::Isolate* isolate, const v8::Local<v8::ObjectTemplate>& proto) : ObjectWrapper(isolate, proto)
{
proto->Set(isolate, "fileInfo", v8::FunctionTemplate::New(isolate, FileInfo));
proto->Set(isolate, "fileName", v8::FunctionTemplate::New(isolate, FileName));
proto->Set(isolate, "filePath", v8::FunctionTemplate::New(isolate, FilePath));
proto->Set(isolate, "hasNext", v8::FunctionTemplate::New(isolate, HasNext));
proto->Set(isolate, "next", v8::FunctionTemplate::New(isolate, Next));
proto->Set(isolate, "path", v8::FunctionTemplate::New(isolate, Path));
}
protected:
static void FileInfo(const v8::FunctionCallbackInfo<v8::Value>& args)
{
V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args)
{
auto* self = UnWrap<QDirIteratorWrapper<T, U, C>>(args.This());
if (!self)
throw std::domain_error(K_CONST_ERROR_CALLED);
}
V8_CREATE_LOCAL_CONTEXT_END
}
static void FileName(const v8::FunctionCallbackInfo<v8::Value>& args)
{
V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args)
{
auto* self = UnWrap<QDirIteratorWrapper<T, U, C>>(args.This());
if (!self)
throw std::domain_error(K_CONST_ERROR_CALLED);
auto retval = (*self)->fileName().toUtf8();
args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, retval.constData()));
}
V8_CREATE_LOCAL_CONTEXT_END
}
static void FilePath(const v8::FunctionCallbackInfo<v8::Value>& args)
{
V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args)
{
auto* self = UnWrap<QDirIteratorWrapper<T, U, C>>(args.This());
if (!self)
throw std::domain_error(K_CONST_ERROR_CALLED);
auto retval = (*self)->filePath().toUtf8();
args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, retval.constData()));
}
V8_CREATE_LOCAL_CONTEXT_END
}
static void HasNext(const v8::FunctionCallbackInfo<v8::Value>& args)
{
V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args)
{
auto* self = UnWrap<QDirIteratorWrapper<T, U, C>>(args.This());
if (!self)
throw std::domain_error(K_CONST_ERROR_CALLED);
args.GetReturnValue().Set((*self)->hasNext());
}
V8_CREATE_LOCAL_CONTEXT_END
}
static void Next(const v8::FunctionCallbackInfo<v8::Value>& args)
{
V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args)
{
auto* self = UnWrap<QDirIteratorWrapper<T, U, C>>(args.This());
if (!self)
throw std::domain_error(K_CONST_ERROR_CALLED);
auto retval = (*self)->next().toUtf8();
args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, retval.constData()));
}
V8_CREATE_LOCAL_CONTEXT_END
}
static void Path(const v8::FunctionCallbackInfo<v8::Value>& args)
{
V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args)
{
auto* self = UnWrap<QDirIteratorWrapper<T, U, C>>(args.This());
if (!self)
throw std::domain_error(K_CONST_ERROR_CALLED);
auto retval = (*self)->path().toUtf8();
args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, retval.constData()));
}
V8_CREATE_LOCAL_CONTEXT_END
}
};
}
}