| 524 | } |
| 525 | |
| 526 | lbug_state lbug_value_get_struct_field_name(lbug_value* value, uint64_t index, char** out_result) { |
| 527 | auto physical_type_id = static_cast<Value*>(value->_value)->getDataType().getPhysicalType(); |
| 528 | if (physical_type_id != PhysicalTypeID::STRUCT) { |
| 529 | return LbugError; |
| 530 | } |
| 531 | auto val = static_cast<Value*>(value->_value); |
| 532 | const auto& data_type = val->getDataType(); |
| 533 | if (index >= StructType::getNumFields(data_type)) { |
| 534 | return LbugError; |
| 535 | } |
| 536 | std::string struct_field_name = StructType::getFields(data_type)[index].getName(); |
| 537 | if (struct_field_name.empty()) { |
| 538 | return LbugError; |
| 539 | } |
| 540 | *out_result = convertToOwnedCString(struct_field_name); |
| 541 | return LbugSuccess; |
| 542 | } |
| 543 | |
| 544 | lbug_state lbug_value_get_struct_field_index(lbug_value* value, const char* field_name, |
| 545 | uint64_t* out_result) { |