@@ -45,6 +45,26 @@ struct PyTestType : mlir::python::PyConcreteType<PyTestType> {
4545 }
4646};
4747
48+ class PyTestAttr : public mlir ::python::PyConcreteAttribute<PyTestAttr> {
49+ public:
50+ static constexpr IsAFunctionTy isaFunction =
51+ mlirAttributeIsAPythonTestTestAttribute;
52+ static constexpr const char *pyClassName = " TestAttr" ;
53+ using PyConcreteAttribute::PyConcreteAttribute;
54+ static constexpr GetTypeIDFunctionTy getTypeIdFunction =
55+ mlirPythonTestTestAttributeGetTypeID;
56+
57+ static void bindDerived (ClassTy &c) {
58+ c.def_static (
59+ " get" ,
60+ [](mlir::python::DefaultingPyMlirContext context) {
61+ return PyTestAttr (context->getRef (), mlirPythonTestTestAttributeGet (
62+ context.get ()->get ()));
63+ },
64+ nb::arg (" context" ).none () = nb::none ());
65+ }
66+ };
67+
4868NB_MODULE (_mlirPythonTestNanobind, m) {
4969 m.def (
5070 " register_python_test_dialect" ,
@@ -84,19 +104,7 @@ NB_MODULE(_mlirPythonTestNanobind, m) {
84104 nb::sig (" def test_diagnostics_with_errors_and_notes(arg: " MAKE_MLIR_PYTHON_QUALNAME (" ir.Context" ) " , /) -> None" ));
85105 // clang-format on
86106
87- mlir_attribute_subclass (m, " TestAttr" ,
88- mlirAttributeIsAPythonTestTestAttribute,
89- mlirPythonTestTestAttributeGetTypeID)
90- .def_classmethod (
91- " get" ,
92- [](const nb::object &cls, MlirContext ctx) {
93- return cls (mlirPythonTestTestAttributeGet (ctx));
94- },
95- // clang-format off
96- nb::sig (" def get(cls: object, context: " MAKE_MLIR_PYTHON_QUALNAME (" ir.Context" ) " | None = None) -> object" ),
97- // clang-format on
98- nb::arg (" cls" ), nb::arg (" context" ).none () = nb::none ());
99-
107+ PyTestAttr::bind (m);
100108 PyTestType::bind (m);
101109
102110 auto typeCls =
0 commit comments