| 263 | } |
| 264 | |
| 265 | static Record MergeCreateConsume(OpBase *opBase) { |
| 266 | OpMergeCreate *op = (OpMergeCreate *)opBase; |
| 267 | Record r; |
| 268 | |
| 269 | // Return mode, all data was consumed. |
| 270 | if(op->handoff_mode) return _handoff(op); |
| 271 | |
| 272 | // Consume mode. |
| 273 | if(!opBase->childCount) { |
| 274 | // No child operation to call. |
| 275 | r = OpBase_CreateRecord(opBase); |
| 276 | |
| 277 | /* Buffer all entity creations. |
| 278 | * If this operation has no children, it should always have unique creations. */ |
| 279 | bool entities_created = _CreateEntities(op, r, op->gc); |
| 280 | ASSERT(entities_created == true); |
| 281 | |
| 282 | // Save record for later use. |
| 283 | array_append(op->records, r); |
| 284 | } else { |
| 285 | // Pull record from child. |
| 286 | r = OpBase_Consume(opBase->children[0]); |
| 287 | if(r) { |
| 288 | /* Create entities. */ |
| 289 | if(_CreateEntities(op, r, op->gc)) { |
| 290 | // Save record for later use. |
| 291 | array_append(op->records, r); |
| 292 | } else { |
| 293 | OpBase_DeleteRecord(r); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | // MergeCreate returns no data while in creation mode. |
| 299 | return NULL; |
| 300 | } |
| 301 | |
| 302 | void MergeCreate_Commit(OpBase *opBase) { |
| 303 | OpMergeCreate *op = (OpMergeCreate *)opBase; |
nothing calls this directly
no test coverage detected