| 86 | }; |
| 87 | |
| 88 | Accumulator* GetAccumulator(sqlite3_context* invocation) { |
| 89 | Accumulator* acc = static_cast<Accumulator*>(sqlite3_aggregate_context(invocation, sizeof(Accumulator))); |
| 90 | if (!acc->initialized) { |
| 91 | assert(acc->value.IsEmpty()); |
| 92 | acc->initialized = true; |
| 93 | if (invoke_start) { |
| 94 | Napi::Value maybeSeed = SafeCall(env, start.Value().As<Napi::Function>(), env.Undefined(), 0, NULL); |
| 95 | if (env.IsExceptionPending()) PropagateJSError(invocation); |
| 96 | else acc->value.Reset(maybeSeed, 1); |
| 97 | } else { |
| 98 | assert(!start.IsEmpty()); |
| 99 | acc->value.Reset(start.Value(), 1); |
| 100 | } |
| 101 | } |
| 102 | return acc; |
| 103 | } |
| 104 | |
| 105 | static void DestroyAccumulator(sqlite3_context* invocation) { |
| 106 | Accumulator* acc = static_cast<Accumulator*>(sqlite3_aggregate_context(invocation, sizeof(Accumulator))); |
nothing calls this directly
no test coverage detected