This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Adapted from a Gist courtesy Eugene Burmako: https://gist.github.com/5845539.html | |
import scala.reflect.runtime.{universe => ru} | |
import scala.tools.reflect.ToolBox | |
import scala.language.reflectiveCalls | |
import scala.tools.scalap.scalax.rules.scalasig._ | |
object Test extends App { | |
def define(tb: ToolBox[ru.type], tree: ru.ImplDef): ru.Symbol = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some(ScalaSig version 5.0 | |
0: ClassSymbol(MyRecord, owner=models, flags=40, info=5 ,None) | |
1: MyRecord | |
2: models | |
3: models | |
4: NoSymbol | |
5: ClassInfoType(ClassSymbol(MyRecord, owner=models, flags=40, info=5 ,None),List(TypeRefType(ThisType(java.lang),java.lang.Object,List()), TypeRefType(ThisType(scala),scala.ScalaObject,List()), TypeRefType(ThisType(scala),scala.Product,List()), TypeRefType(ThisType(scala),scala.Serializable,List()))) | |
6: TypeRefType(ThisType(java.lang),java.lang.Object,List()) | |
7: ThisType(java.lang) | |
8: java.lang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ClassWriter cw = new ClassWriter(0); | |
FieldVisitor fv; | |
MethodVisitor mv; | |
AnnotationVisitor av0; | |
cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "models/rec", null, "java/lang/Object", new String[] { "scala/ScalaObject", "scala/Product", "scala/Serializable" }); | |
{ | |
av0 = cw.visitAnnotation("Lscala/reflect/ScalaSignature;", true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ScalaSig version 5.0 | |
0: ClassSymbol(MyRecordA, owner=<empty>, flags=40, info=5 ,None) | |
1: MyRecordA | |
2: <empty> | |
3: <empty> | |
4: NoSymbol | |
5: ClassInfoType(ClassSymbol(MyRecordA, owner=<empty>, flags=40, info=5 ,None),List(TypeRefType(ThisType(scala),scala.AnyRef,List()), TypeRefType(ThisType(scala),scala.Product,List()), TypeRefType(ThisType(scala),scala.Serializable,List()))) | |
6: TypeRefType(ThisType(scala),scala.AnyRef,List()) | |
7: ThisType(scala) | |
8: scala |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val sig = "\u0006\u0001\u0005\rc\u0001B\u0001\u0003\u0001\u0016\u0011\u0001\"T=SK\u000e|'\u000f\u001a\u0006\u0002\u0007\u00051Qn\u001c3fYN\u001c\u0001a\u0005\u0003\u0001\r1y\u0001CA\u0004\u000b\u001b\u0005A!\"A\u0005\u0002\u000bM\u001c\u0017\r\\1\n\u0005-A!AB!osJ+g\r\u0005\u0002\u0008\u001b%\u0011a\u0002\u0003\u0002\u0008!J|G-^2u!\u00099\u0001#\u0003\u0002\u0012\u0011\u0009a1+\u001a:jC2L'0\u00192mK\"A1\u0003\u0001BK\u0002\u0013\u0005A#A\u0001y+\u0005)\u0002C\u0001\u000c\u001a\u001d\u00099q#\u0003\u0002\u0019\u0011\u00051\u0001K]3eK\u001aL!AG\u000e\u0003\rM#(/\u001b8h\u0015\u0009A\u0002\u0002\u0003\u0005\u001e\u0001\u0009E\u0009\u0015!\u0003\u0016\u0003\u0009A\u0008\u0005\u0003\u0005 \u0001\u0009U\r\u0011\"\u0001!\u0003\u0005IX#A\u0011\u0011\u0005\u001d\u0011\u0013BA\u0012\u0009\u0005\rIe\u000e\u001e\u0005\u0009K\u0001\u0011\u0009\u0012)A\u0005C\u0005\u0011\u0011\u0010\u0009\u0005\u0009O\u0001\u0011)\u001a!C\u0001Q\u0005\u0009!0F\u0001*!\u00099!&\u0003\u0002,\u0011\u00099!i\\8mK\u0006t\u0007\u0002C\u0017\u0001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sbt run | |
Loading /usr/share/sbt/bin/sbt-launch-lib.bash | |
[warn] The global sbt directory is now versioned and is located at /home/julianpeeters/.sbt/0.13. | |
[warn] You are seeing this warning because there is global configuration in /home/julianpeeters/.sbt but not in /home/julianpeeters/.sbt/0.13. | |
[warn] The global sbt directory may be changed via the sbt.global.base system property. | |
[info] Loading project definition from /home/julianpeeters/Dropbox/macro-annotation-example/project | |
[info] Updating {file:/home/julianpeeters/Dropbox/macro-annotation-example/project/}macro-annotation-example-build... | |
[info] Resolving org.fusesource.jansi#jansi;1.4 ... | |
[info] Done updating. | |
[info] Compiling 1 Scala source to /home/julianpeeters/Dropbox/macro-annotation-example/project/target/scala-2.10/sbt-0.13/classes... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
import scala.reflect.macros.Context | |
import scala.language.experimental.macros | |
import scala.annotation.StaticAnnotation | |
import scala.io._ | |
object helloMacro { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
import scala.reflect.macros.Context | |
import scala.language.experimental.macros | |
import scala.annotation.StaticAnnotation | |
import scala.io._ | |
object nestedInnerMacro { | |
def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
accipiter:vagrant-cascading-hadoop-cluster julianpeeters$ git pull | |
Already up-to-date. | |
accipiter:vagrant-cascading-hadoop-cluster julianpeeters$ git checkout 2.2 | |
Already on '2.2' | |
accipiter:vagrant-cascading-hadoop-cluster julianpeeters$ vagrant destroy -f | |
[master] Destroying VM and associated drives... | |
[master] Running cleanup tasks for 'puppet' provisioner... | |
[master] Running cleanup tasks for 'puppet' provisioner... | |
[master] Running cleanup tasks for 'puppet' provisioner... | |
[master] Running cleanup tasks for 'puppet' provisioner... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run | |
[info] Compiling 1 Scala source to /home/julianpeeters/Dropbox/macro-annotation-example/macros/target/scala-2.10/classes... | |
[info] Compiling 2 Scala sources to /home/julianpeeters/Dropbox/macro-annotation-example/core/target/scala-2.10/classes... | |
while compiling: /home/julianpeeters/Dropbox/macro-annotation-example/core/src/main/scala/models/MyRecord.scala | |
during phase: uncurry | |
library version: version 2.10.3 | |
compiler version: version 2.10.3 | |
reconstructed args: -bootclasspath /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/netx.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/plugin.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/li |
OlderNewer