aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/options/OptionsView.scala
diff options
context:
space:
mode:
authorJack Koenig2019-04-26 13:10:44 -0700
committerGitHub2019-04-26 13:10:44 -0700
commita7cf6ff3416a11088d811a435ba71fd36b191fb4 (patch)
tree79e2e8c5753903ca6d14e9b952c26a07442bd980 /src/main/scala/firrtl/options/OptionsView.scala
parent99ae1d6649f1731c5dec2098b10733735232b72c (diff)
parentef8f06f23b9ee6cf86de2450752dfd0fcd32da80 (diff)
Merge pull request #1005 from freechipsproject/f764.7
Stage/Phase
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)
}