@@ -35,10 +35,17 @@ Returns the components of the interface, as a `NamedTuple` of `NamedTuple`.
3535"""
3636function components end
3737
38+ """
39+ requiredtype(::Type{<:Interface})
40+
41+ Returns the supertype required for all interface implementations.
42+ """
43+ function requiredtype end
44+
3845"""
3946@interface(interfacename, components, [description])
4047
41- Define an interface.
48+ Define an interface that can apply to types `<: Any` .
4249
4350```julia
4451components = (
@@ -50,17 +57,19 @@ components = (
5057)
5158description = "A description of the interface"
5259
53- @interface MyInterface components description
60+ @interface MyInterface Any components description
5461```
5562"""
56- macro interface(interface:: Symbol , components, description)
63+ macro interface(interface:: Symbol , type, components, description)
5764 quote
65+ @assert $ type isa Type
66+ @assert $ components isa NamedTuple{(:mandatory,:optional)}
67+ @assert $ description isa String
5868 # Define the interface type (should it be concrete?)
5969 abstract type $ interface{Components} <: $Interfaces.Interface{Components} end
6070 # Define the interface component methods
61- @assert $ components isa NamedTuple{(:mandatory,:optional)}
71+ $ Interfaces . requiredtype( :: Type{<:$interface} ) = $ type
6272 $ Interfaces. components(:: Type{<:$interface} ) = $ components
63- @assert $ description isa String
6473 $ Interfaces. description(:: Type{<:$interface} ) = $ description
6574 # Generate a docstring for the interface
6675 let description= $ description,
0 commit comments