MCPcopy Create free account
hub / github.com/WiseLibs/better-sqlite3 / GetAccumulator

Method GetAccumulator

src/util/custom-aggregate.cpp:88–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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)));

Callers

nothing calls this directly

Calls 1

SafeCallFunction · 0.85

Tested by

no test coverage detected