Skip to content

Commit dd24030

Browse files
committed
Removes unused function-caching adaptors
1 parent 0f64578 commit dd24030

File tree

1 file changed

+0
-75
lines changed

1 file changed

+0
-75
lines changed

src/adaptors.h

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -48,81 +48,6 @@ template <typename Matrix> inline auto makeMatrixFromFunction(std::int32_t n, v8
4848
return matrix;
4949
}
5050

51-
// Caches user provided Function(node) -> [start, stop] into TimeWindows
52-
inline auto makeTimeWindowsFromFunction(std::int32_t n, v8::Local<v8::Function> fn) {
53-
if (n < 0)
54-
throw std::runtime_error{"Negative size"};
55-
56-
Nan::Callback callback{fn};
57-
58-
TimeWindows timeWindows{n};
59-
60-
for (std::int32_t atIdx = 0; atIdx < n; ++atIdx) {
61-
const auto argc = 1u;
62-
v8::Local<v8::Value> argv[argc] = {Nan::New(atIdx)};
63-
64-
auto interval = callback.Call(argc, argv);
65-
66-
if (!interval->IsArray())
67-
throw std::runtime_error{"Expected function signature: Array fn(Number at)"};
68-
69-
auto intervalArray = interval.As<v8::Array>();
70-
71-
if (intervalArray->Length() != 2)
72-
throw std::runtime_error{"Expected interval array of shape [start, stop]"};
73-
74-
auto start = Nan::Get(intervalArray, 0).ToLocalChecked();
75-
auto stop = Nan::Get(intervalArray, 1).ToLocalChecked();
76-
77-
if (!start->IsNumber() || !stop->IsNumber())
78-
throw std::runtime_error{"Expected interval start and stop of type Number"};
79-
80-
Interval out{Nan::To<std::int32_t>(start).FromJust(), Nan::To<std::int32_t>(stop).FromJust()};
81-
timeWindows.at(atIdx) = std::move(out);
82-
}
83-
84-
return timeWindows;
85-
}
86-
87-
// Caches user provided Function(vehicle) -> [node0, node1, ..] into RouteLocks
88-
inline auto makeRouteLocksFromFunction(std::int32_t n, v8::Local<v8::Function> fn) {
89-
if (n < 0)
90-
throw std::runtime_error{"Negative size"};
91-
92-
Nan::Callback callback{fn};
93-
94-
// Note: use (n) for construction because RouteLocks is a weak alias to a std::vector.
95-
// Using vec(n) creates a vector of n items, using vec{n} creates a vector with a single element n.
96-
RouteLocks routeLocks(n);
97-
98-
for (std::int32_t atIdx = 0; atIdx < n; ++atIdx) {
99-
const auto argc = 1u;
100-
v8::Local<v8::Value> argv[argc] = {Nan::New(atIdx)};
101-
102-
auto locks = callback.Call(argc, argv);
103-
104-
if (!locks->IsArray())
105-
throw std::runtime_error{"Expected function signature: Array fn(Number vehicle)"};
106-
107-
auto locksArray = locks.As<v8::Array>();
108-
109-
LockChain lockChain(locksArray->Length());
110-
111-
for (std::int32_t lockIdx = 0; lockIdx < (std::int32_t)locksArray->Length(); ++lockIdx) {
112-
auto node = Nan::Get(locksArray, lockIdx).ToLocalChecked();
113-
114-
if (!node->IsNumber())
115-
throw std::runtime_error{"Expected lock node of type Number"};
116-
117-
lockChain.at(lockIdx) = Nan::To<std::int32_t>(node).FromJust();
118-
}
119-
120-
routeLocks.at(atIdx) = std::move(lockChain);
121-
}
122-
123-
return routeLocks;
124-
}
125-
12651
// Caches user provided Js Array into a Vector
12752
template <typename Vector> inline auto makeVectorFromJsNumberArray(v8::Local<v8::Array> array) {
12853
const std::int32_t len = array->Length();

0 commit comments

Comments
 (0)