| 8 | namespace LIEF::dwarf::py { |
| 9 | template<> |
| 10 | void create<dw::editor::StructType>(nb::module_& m) { |
| 11 | nb::class_<dw::editor::StructType, dw::editor::Type> S(m, "StructType", |
| 12 | R"doc( |
| 13 | This class represents a struct-like type which can be: |
| 14 | |
| 15 | - ``DW_TAG_class_type`` |
| 16 | - ``DW_TAG_structure_type`` |
| 17 | - ``DW_TAG_union_type`` |
| 18 | )doc"_doc |
| 19 | ); |
| 20 | |
| 21 | using TYPE = dw::editor::StructType::TYPE; |
| 22 | nb::enum_<TYPE>(S, "TYPE") |
| 23 | .value("CLASS", TYPE::CLASS, "Discriminant for ``DW_TAG_class_type``"_doc) |
| 24 | .value("STRUCT", TYPE::STRUCT, "Discriminant for ``DW_TAG_structure_type``"_doc) |
| 25 | .value("UNION", TYPE::UNION, "Discriminant for ``DW_TAG_union_type``"_doc); |
| 26 | |
| 27 | nb::class_<dw::editor::StructType::Member>(S, "Member", |
| 28 | "This class represents a member of the struct-like"_doc |
| 29 | ); |
| 30 | |
| 31 | S |
| 32 | .def("set_size", &dw::editor::StructType::set_size, |
| 33 | R"doc( |
| 34 | Define the overall size which is equivalent to the ``sizeof`` of the |
| 35 | current type. |
| 36 | |
| 37 | This function defines the ``DW_AT_byte_size`` attribute |
| 38 | )doc"_doc, "size"_a, nb::rv_policy::reference_internal) |
| 39 | |
| 40 | .def("add_member", &dw::editor::StructType::add_member, |
| 41 | "mber to the current struct-like"_doc, |
| 42 | "name"_a, "type"_a, "offset"_a = -1) |
| 43 | ; |
| 44 | } |
| 45 | |
| 46 | } |