Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. class json extends StaticAnnotation {
  2. def macroTransform(annottees: Any*) = macro impl
  3.  
  4. private def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {
  5. import c.universe._
  6.  
  7. def modifiedClass(classDecl: ClassDef, compDeclOpt: Option[ModuleDef]) = {
  8. // Class modification logic goes here
  9. }
  10.  
  11. annottees.map(_.tree) match {
  12. case (classDecl: ClassDef) :: Nil => modifiedClass(c, classDecl)
  13. case (classDecl: ClassDef) :: (compDecl: ModuleDef) :: Nil => modifiedClass(c, classDecl, Some(compDecl))
  14. case _ => c.abort(c.enclosingPosition, "Invalid annottee")
  15. }
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement