| 502 | static void GetAdHocMetatable(lua_State *state, const struct_field_info *field); |
| 503 | |
| 504 | static void read_field(lua_State *state, const struct_field_info *field, void *ptr) |
| 505 | { |
| 506 | switch (field->mode) |
| 507 | { |
| 508 | case struct_field_info::STATIC_STRING: |
| 509 | { |
| 510 | int len = strnlen((char*)ptr, field->count); |
| 511 | lua_pushlstring(state, (char*)ptr, len); |
| 512 | return; |
| 513 | } |
| 514 | |
| 515 | case struct_field_info::OBJ_METHOD: |
| 516 | case struct_field_info::CLASS_METHOD: |
| 517 | // error |
| 518 | |
| 519 | case struct_field_info::PRIMITIVE: |
| 520 | case struct_field_info::SUBSTRUCT: |
| 521 | field->type->lua_read(state, 2, ptr); |
| 522 | return; |
| 523 | |
| 524 | case struct_field_info::POINTER: |
| 525 | df::pointer_identity::lua_read(state, 2, ptr, field->type); |
| 526 | return; |
| 527 | |
| 528 | case struct_field_info::CONTAINER: |
| 529 | if (!field->extra || !field->extra->index_enum || !field->type->isContainer() || |
| 530 | field->extra->index_enum == ((container_identity*)field->type)->getIndexEnumType()) |
| 531 | { |
| 532 | field->type->lua_read(state, 2, ptr); |
| 533 | return; |
| 534 | } |
| 535 | // fallthrough |
| 536 | |
| 537 | case struct_field_info::STATIC_ARRAY: |
| 538 | case struct_field_info::STL_VECTOR_PTR: |
| 539 | GetAdHocMetatable(state, field); |
| 540 | push_object_ref(state, ptr); |
| 541 | return; |
| 542 | |
| 543 | case struct_field_info::END: |
| 544 | break; |
| 545 | } |
| 546 | |
| 547 | lua_pushnil(state); |
| 548 | } |
| 549 | |
| 550 | static void field_reference(lua_State *state, const struct_field_info *field, void *ptr) |
| 551 | { |
no test coverage detected