martmists
04/20/2022, 11:16 AMshikasd
04/20/2022, 12:01 PMmartmists
04/20/2022, 12:35 PMmartmists
04/20/2022, 12:41 PMcontext(IrPluginContext, KPyPackage)
private fun generatePyMethod(method: KPyMethod) {
// TODO: val `${name}-kpy-method` = staticCFunction { ... }
// TODO: val `${name}-kpy-def` = `${name}-kpy-method`.pydef(...)
irFactory.buildProperty {
this.name = Name.identifier(method.name + "-kpy-method")
this.modality = Modality.FINAL
this.visibility = DescriptorVisibilities.INTERNAL
}.also { prop ->
prop.backingField = irFactory.buildField {
this.name = Name.identifier(method.name + "-kpy-method")
this.type = classFuncType.owner.expandedType
}.also { field ->
TODO("Set initializer")
}
TODO("addDefaultGetter needs a parent class?")
// prop.addDefaultGetter(???, irBuiltIns)
}
}
For 2/4:
val classPyObjectT = context.referenceTypeAlias(FqName("kpy.wrappers.PyObjectT"))!!.owner.expandedType
val classFuncType = context.referenceTypeAlias(FqName("kpy.wrappers.FuncType"))!! // How do I add a generic type parameter to this somehow? owner.expandedType does not have a withType function or anything
val classMethodT = context.referenceTypeAlias(FqName("kpy.wrappers.PyMethodT"))!!.owner.expandedType
val classMethodKwargsT = context.referenceTypeAlias(FqName("kpy.wrappers.PyMethodKwargsT"))!!.owner.expandedType
For 3 I'm clueless sadly, might be due to the way I'm testing (a test in jvm source, since I have no clue how to make a sibling project test a gradle plugin)shikasd
04/20/2022, 1:35 PMshikasd
04/20/2022, 1:36 PMmartmists
04/20/2022, 2:00 PMmartmists
04/20/2022, 2:06 PM