forked from OP-Engineering/op-sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmartHostObject.cpp
More file actions
34 lines (25 loc) · 767 Bytes
/
Copy pathSmartHostObject.cpp
File metadata and controls
34 lines (25 loc) · 767 Bytes
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
#include "SmartHostObject.h"
#include "utils.h"
namespace opsqlite {
namespace jsi = facebook::jsi;
std::vector<jsi::PropNameID>
SmartHostObject::getPropertyNames(jsi::Runtime &rt) {
std::vector<jsi::PropNameID> keys;
keys.reserve(fields.size());
for (const auto &field : fields) {
keys.emplace_back(jsi::PropNameID::forAscii(rt, field.first));
}
return keys;
}
jsi::Value SmartHostObject::get(jsi::Runtime &rt,
const jsi::PropNameID &propNameID) {
auto name = propNameID.utf8(rt);
for (const auto &field : fields) {
auto fieldName = field.first;
if (fieldName == name) {
return to_jsi(rt, field.second);
}
}
return {};
}
} // namespace opsqlite