Skip to content

Commit 73f1223

Browse files
committed
fix: apply consequences of static method
1 parent 446380a commit 73f1223

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

mlir/lib/Bindings/Python/IRCore.cpp

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,10 +2731,11 @@ class PyOpAttributeMap {
27312731
}
27322732

27332733
static void
2734-
forEachAttr(llvm::function_ref<void(MlirStringRef, MlirAttribute)> fn) {
2735-
intptr_t n = mlirOperationGetNumAttributes(operation->get());
2734+
forEachAttr(MlirOperation op,
2735+
llvm::function_ref<void(MlirStringRef, MlirAttribute)> fn) {
2736+
intptr_t n = mlirOperationGetNumAttributes(op);
27362737
for (intptr_t i = 0; i < n; ++i) {
2737-
MlirNamedAttribute na = mlirOperationGetAttribute(operation->get(), i);
2738+
MlirNamedAttribute na = mlirOperationGetAttribute(op, i);
27382739
MlirStringRef name = mlirIdentifierStr(na.name);
27392740
fn(name, na.attribute);
27402741
}
@@ -2751,36 +2752,44 @@ class PyOpAttributeMap {
27512752
.def("__iter__",
27522753
[](PyOpAttributeMap &self) {
27532754
nb::list keys;
2754-
self.forEachAttr([&](MlirStringRef name, MlirAttribute) {
2755-
keys.append(nb::str(name.data, name.length));
2756-
});
2755+
PyOpAttributeMap::forEachAttr(
2756+
self.operation->get(),
2757+
[&](MlirStringRef name, MlirAttribute) {
2758+
keys.append(nb::str(name.data, name.length));
2759+
});
27572760
return nb::iter(keys);
27582761
})
27592762
.def("keys",
27602763
[](PyOpAttributeMap &self) {
27612764
nb::list out;
2762-
self.forEachAttr([&](MlirStringRef name, MlirAttribute) {
2763-
out.append(nb::str(name.data, name.length));
2764-
});
2765+
PyOpAttributeMap::forEachAttr(
2766+
self.operation->get(),
2767+
[&](MlirStringRef name, MlirAttribute) {
2768+
out.append(nb::str(name.data, name.length));
2769+
});
27652770
return out;
27662771
})
27672772
.def("values",
27682773
[](PyOpAttributeMap &self) {
27692774
nb::list out;
2770-
self.forEachAttr([&](MlirStringRef, MlirAttribute attr) {
2771-
out.append(PyAttribute(self.operation->getContext(), attr)
2772-
.maybeDownCast());
2773-
});
2775+
PyOpAttributeMap::forEachAttr(
2776+
self.operation->get(),
2777+
[&](MlirStringRef, MlirAttribute attr) {
2778+
out.append(PyAttribute(self.operation->getContext(), attr)
2779+
.maybeDownCast());
2780+
});
27742781
return out;
27752782
})
27762783
.def("items", [](PyOpAttributeMap &self) {
27772784
nb::list out;
2778-
self.forEachAttr([&](MlirStringRef name, MlirAttribute attr) {
2779-
out.append(
2780-
nb::make_tuple(nb::str(name.data, name.length),
2781-
PyAttribute(self.operation->getContext(), attr)
2782-
.maybeDownCast()));
2783-
});
2785+
PyOpAttributeMap::forEachAttr(
2786+
self.operation->get(),
2787+
[&](MlirStringRef name, MlirAttribute attr) {
2788+
out.append(nb::make_tuple(
2789+
nb::str(name.data, name.length),
2790+
PyAttribute(self.operation->getContext(), attr)
2791+
.maybeDownCast()));
2792+
});
27842793
return out;
27852794
});
27862795
}

0 commit comments

Comments
 (0)