| 88 | }; |
| 89 | |
| 90 | inline void TIntObj::RegisterReflection() { |
| 91 | namespace refl = tvm::ffi::reflection; |
| 92 | refl::ObjectDef<TIntObj>() |
| 93 | .def_ro("value", &TIntObj::value) |
| 94 | .def_static("static_add", &TInt::StaticAdd, "static add method"); |
| 95 | // define extra type attributes |
| 96 | refl::TypeAttrDef<TIntObj>() |
| 97 | .def("test.GetValue", &TIntObj::GetValue) |
| 98 | .attr("test.size", sizeof(TIntObj)) |
| 99 | .attr(refl::type_attr::kAnyHash, reinterpret_cast<void*>(&TInt::CustomAnyHash)) |
| 100 | .attr(refl::type_attr::kAnyEqual, reinterpret_cast<void*>(&TInt::CustomAnyEqual)); |
| 101 | // custom json serialization |
| 102 | refl::TypeAttrDef<TIntObj>() |
| 103 | .def(refl::type_attr::kDataToJson, |
| 104 | [](const TIntObj* self) -> Map<String, Any> { |
| 105 | return Map<String, Any>{{"value", self->value}}; |
| 106 | }) |
| 107 | .def(refl::type_attr::kDataFromJson, [](Map<String, Any> json_obj) -> TInt { |
| 108 | return TInt(json_obj["value"].cast<int64_t>()); |
| 109 | }); |
| 110 | } |
| 111 | |
| 112 | class TFloatObj : public TNumberObj { |
| 113 | public: |
nothing calls this directly
no test coverage detected