inkwell
inkwell copied to clipboard
Roll up type and value trait definitions into existing macro
As of #22, value and type trait definitions are no longer a part of the trait macro. It would be great to roll this all back up into the macro, but this would probably require procedural macros (at the very least for converting the associated enum type into a snake case method, if not more). Procedural macros only support derives right now IIRC and require a separate crate, both of which aren't ideal. Maybe we can hardcode the method name into the regular macro invocation to avoid the trouble...
I'm imagining something like:
trait_type_set! {
/// Represents any LLVM type.
AnyType requires AsTypeRef + Debug enumerated by AnyTypeEnum [
BasicTypeEnum, IntType, FunctionType, FloatType, PointerType, StructType, ArrayType, VoidType, VectorType
]
}
Which would expand to:
/// Represents any LLVM type.
pub trait AnyType: AsTypeRef + Debug {
/// Returns a `AnyTypeEnum` that represents the current type.
fn as_any_type_enum(&self) -> AnyTypeEnum {
AnyTypeEnum::new(self.as_type_ref())
}
}
along with the trait impl
s for each provided type.
This isn't a big deal, but would make traits more DRY, so I'm leaving this as a wishlist item.