This method advances a virtual table's cursor to the next row. SQLite will call this method repeatedly, driving the generator function.
| 229 | // This method advances a virtual table's cursor to the next row. |
| 230 | // SQLite will call this method repeatedly, driving the generator function. |
| 231 | static int xNext(sqlite3_vtab_cursor* _cursor) { |
| 232 | Cursor* cursor = Cursor::Upcast(_cursor); |
| 233 | CustomTable* self = cursor->GetVTab()->parent; |
| 234 | Addon* addon = self->addon; |
| 235 | Napi::Env env = self->env; |
| 236 | Napi::HandleScope scope(env); |
| 237 | |
| 238 | Napi::Object iterator = cursor->iterator.Value(); |
| 239 | Napi::Function next = cursor->next.Value(); |
| 240 | |
| 241 | Napi::Value maybeRecord = SafeCall(env, next, iterator, 0, NULL); |
| 242 | if (env.IsExceptionPending()) { |
| 243 | self->PropagateJSError(); |
| 244 | return SQLITE_ERROR; |
| 245 | } |
| 246 | |
| 247 | Napi::Object record = maybeRecord.As<Napi::Object>(); |
| 248 | bool done = record.Get(addon->cs.done.Value()).As<Napi::Boolean>().Value(); |
| 249 | if (!done) { |
| 250 | cursor->row.Reset(record.Get(addon->cs.value.Value()).As<Napi::Array>(), 1); |
| 251 | } |
| 252 | cursor->done = done; |
| 253 | cursor->rowid += 1; |
| 254 | |
| 255 | return SQLITE_OK; |
| 256 | } |
| 257 | |
| 258 | // If this method returns 1, SQLite will stop scanning the virtual table. |
| 259 | static int xEof(sqlite3_vtab_cursor* cursor) { |
nothing calls this directly
no test coverage detected