Suppose I have a setup like this (I'm simplifying things a lot).
@Domain
struct SimpleDomain {
struct Properties {
var color: Color
var area: Int
}
struct ObjectProperties {
var object: Object
}
struct GroupProperties {
var group: Group
}
}
Now suppose I want the Domain macro to find the struct named Properties
, extract its vars, and insert them into the other structs as computed properties. Is there any way to do this?
I'm experimenting with Domain as a member macro. I can find each of the nested structs, and find all of their vars. But I don't see any way I can modify ObjectProperties
and GroupProperties
. I don't think there's any way for a macro working at the level of the SimpleDomain
struct to insert code inside the nested structs. And I can't extend ObjectProperties
because you can't extend a struct inside another one (I know you can use extension SimpleDomain.ObjectProperties
, but I doubt any macro can do that).
Alternatively, I could try applying a member macro directly to ObjectProperties
and GroupProperties
. But I don't know how that macro would have access to the vars defined inside Properties
.
Any suggestions would be welcome. Thanks.