| 356 | } |
| 357 | |
| 358 | void |
| 359 | DictObject::loadFromPython3(remote_addr_t addr) |
| 360 | { |
| 361 | Structure<py_dict_v> dict(d_manager, addr); |
| 362 | |
| 363 | ssize_t num_items; |
| 364 | std::vector<Python3::PyDictKeyEntry> valid_entries; |
| 365 | |
| 366 | getDictEntries(d_manager, dict, num_items, valid_entries); |
| 367 | |
| 368 | // Copy the keys |
| 369 | d_keys.reserve(valid_entries.size()); |
| 370 | std::transform( |
| 371 | valid_entries.cbegin(), |
| 372 | valid_entries.cend(), |
| 373 | std::back_inserter(d_keys), |
| 374 | [](auto& entry) { return (remote_addr_t)entry.me_key; }); |
| 375 | |
| 376 | /* The DictObject can be in one of two forms. |
| 377 | * |
| 378 | * Either: |
| 379 | * A combined table: |
| 380 | * ma_values == NULL, dk_refcnt == 1. |
| 381 | * Values are stored in the me_value field of the PyDictKeysObject. |
| 382 | * Or: |
| 383 | * A split table: |
| 384 | * ma_values != NULL, dk_refcnt >= 1 |
| 385 | * Values are stored in the ma_values array. |
| 386 | * Only string (unicode) keys are allowed. |
| 387 | * All dicts sharing same key must have same insertion order. |
| 388 | */ |
| 389 | |
| 390 | remote_addr_t dictvalues_addr = dict.getField(&py_dict_v::o_ma_values); |
| 391 | Structure<py_dictvalues_v> dictvalues(d_manager, dictvalues_addr); |
| 392 | |
| 393 | // Get the values in one copy if we are dealing with a split-table dictionary |
| 394 | if (dictvalues_addr != 0) { |
| 395 | d_values.resize(num_items); |
| 396 | auto values_addr = dictvalues.getFieldRemoteAddress(&py_dictvalues_v::o_values); |
| 397 | d_manager->copyMemoryFromProcess(values_addr, num_items * sizeof(PyObject*), d_values.data()); |
| 398 | } else { |
| 399 | std::transform( |
| 400 | valid_entries.cbegin(), |
| 401 | valid_entries.cend(), |
| 402 | std::back_inserter(d_values), |
| 403 | [](auto& entry) { return (remote_addr_t)entry.me_value; }); |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | void |
| 408 | DictObject::loadFromPython2(remote_addr_t addr) |
nothing calls this directly
no test coverage detected