| 447 | } |
| 448 | |
| 449 | void DDFToLuaValue(lua_State* L, const dmDDF::FieldDescriptor* f, const char* data, uintptr_t pointers_offset) |
| 450 | { |
| 451 | DM_PROFILE("DDFToLuaValue"); |
| 452 | |
| 453 | const char* where = &data[f->m_Offset]; |
| 454 | uint32_t count; |
| 455 | bool array; |
| 456 | |
| 457 | uint32_t type = f->m_Type; |
| 458 | if (f->m_Label == dmDDF::LABEL_REPEATED) |
| 459 | { |
| 460 | dmDDF::RepeatedField* repeated = (dmDDF::RepeatedField*) &data[f->m_Offset]; |
| 461 | where = (const char*)(repeated->m_Array + pointers_offset); |
| 462 | count = repeated->m_ArrayCount; |
| 463 | array = true; |
| 464 | |
| 465 | lua_createtable(L, count, 0); |
| 466 | } |
| 467 | else |
| 468 | { |
| 469 | array = false; |
| 470 | count = 1; |
| 471 | where = &data[f->m_Offset]; |
| 472 | } |
| 473 | |
| 474 | const int* iptr = (int32_t*) where; |
| 475 | const uint32_t* uptr = (uint32_t*) where; |
| 476 | const dmhash_t* hptr = (dmhash_t*) where; |
| 477 | const float* fptr = (float*) where; |
| 478 | const bool* bptr = (bool*) where; |
| 479 | |
| 480 | for (uint32_t i=0;i!=count;i++) |
| 481 | { |
| 482 | switch (type) |
| 483 | { |
| 484 | case dmDDF::TYPE_ENUM: |
| 485 | case dmDDF::TYPE_INT32: |
| 486 | { |
| 487 | lua_pushinteger(L, iptr[i]); |
| 488 | } |
| 489 | break; |
| 490 | |
| 491 | case dmDDF::TYPE_UINT32: |
| 492 | { |
| 493 | lua_pushinteger(L, (int)uptr[i]); |
| 494 | } |
| 495 | break; |
| 496 | |
| 497 | case dmDDF::TYPE_UINT64: |
| 498 | { |
| 499 | dmScript::PushHash(L, hptr[i]); |
| 500 | } |
| 501 | break; |
| 502 | |
| 503 | case dmDDF::TYPE_BOOL: |
| 504 | { |
| 505 | lua_pushboolean(L, bptr[i]); |
| 506 | } |
no test coverage detected