martmists
12/25/2021, 6:34 PMYoussef Shoaib [MOD]
12/26/2021, 12:01 PMmartmists
12/26/2021, 1:14 PMmartmists
12/26/2021, 1:14 PMmartmists
12/26/2021, 1:17 PMprivate val getattroConfigurable = staticCFunction { self: PyObjectT, attr: PyObjectT ->
val obj = self!!.kt.cast<Configurable>()
val name = attr.toKotlin<String>()
val attrObj = obj.attrs[name]
if (attrObj != null) {
attrObj.get().toPython()
} else {
PyObject_GenericGetAttr(self, attr)
}
}
where I use lambda arguments, not null assertions, generics, type aliases, conditions, external method calls, and so on.martmists
12/26/2021, 1:19 PMYoussef Shoaib [MOD]
12/26/2021, 5:15 PMCollectAdditionalSourcesExtension
. Using that, you can then in the IR phase look at the IR of your compiled template, and you can copy it over multiple times (using IrElement.deepCopyWithSymbols
) and you can edit specific elements of it to match your desired output (for example, you can refer to specific functions, or you can delete certain elements, or get certain values).Youssef Shoaib [MOD]
12/26/2021, 5:15 PMmartmists
12/26/2021, 10:01 PMmartmists
12/26/2021, 10:02 PM