aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/options/OptionsView.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/firrtl/options/OptionsView.scala')
-rw-r--r--src/main/scala/firrtl/options/OptionsView.scala19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main/scala/firrtl/options/OptionsView.scala b/src/main/scala/firrtl/options/OptionsView.scala
index aacd997e..4235b660 100644
--- a/src/main/scala/firrtl/options/OptionsView.scala
+++ b/src/main/scala/firrtl/options/OptionsView.scala
@@ -4,26 +4,31 @@ package firrtl.options
import firrtl.AnnotationSeq
-/** Type class defining a "view" of an [[AnnotationSeq]]
- * @tparam T the type to which this viewer converts an [[AnnotationSeq]] to
+/** Type class defining a "view" of an [[firrtl.AnnotationSeq AnnotationSeq]]
+ * @tparam T the type to which this viewer converts an [[firrtl.AnnotationSeq AnnotationSeq]] to
*/
trait OptionsView[T] {
- /** Convert an [[AnnotationSeq]] to some other type
+ /** Convert an [[firrtl.AnnotationSeq AnnotationSeq]] to some other type
* @param options some annotations
*/
def view(options: AnnotationSeq): T
}
-/** A shim to manage multiple "views" of an [[AnnotationSeq]] */
+/** A shim to manage multiple "views" of an [[firrtl.AnnotationSeq AnnotationSeq]] */
object Viewer {
+ /** Helper method to get at a given [[OptionsView]]. This enables access to [[OptionsView]] methods in a more canonical
+ * format, e.g., you can then do `Viewer[T].view`.
+ * @param a an implicit [[OptionsView]]
+ */
+ def apply[T](implicit a: OptionsView[T]): OptionsView[T] = a
+
/** Convert annotations to options using an implicitly provided [[OptionsView]]
* @param options some annotations
- * @param optionsView a converter of options to the requested type
- * @tparam T the type to which the input [[AnnotationSeq]] should be viewed as
+ * @tparam T the type to which the input [[firrtl.AnnotationSeq AnnotationSeq]] should be viewed as
*/
- def view[T](options: AnnotationSeq)(implicit optionsView: OptionsView[T]): T = optionsView.view(options)
+ def view[T: OptionsView](options: AnnotationSeq): T = Viewer[T].view(options)
}