diff options
author | mihaylov <mihaylov@epfl.ch> | 2006-02-10 11:37:35 +0000 |
---|---|---|
committer | mihaylov <mihaylov@epfl.ch> | 2006-02-10 11:37:35 +0000 |
commit | 14a08beabff59f245ddd220d4097ce43996cf3e1 (patch) | |
tree | 8c0847ad4fc7480e1541fd1e40f0ab63866fd6c7 /src/compiler | |
parent | c904af67cebbcfabac41bd3783a62fec659df53d (diff) | |
download | scala-14a08beabff59f245ddd220d4097ce43996cf3e1.tar.gz scala-14a08beabff59f245ddd220d4097ce43996cf3e1.tar.bz2 scala-14a08beabff59f245ddd220d4097ce43996cf3e1.zip |
Interpet the scala.runtime.compat.BeanProperty ...
Interpet the scala.runtime.compat.BeanProperty to generate Java Beans
compliant names for variable accessors
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala | 17 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Definitions.scala | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 7b9c00016a..b4f4fd87f2 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -63,6 +63,7 @@ abstract class GenJVM extends SubComponent { val TransientAtt = definitions.getClass("scala.transient").tpe; val VolatileAttr = definitions.getClass("scala.volatile").tpe; val RemoteAttr = definitions.getClass("scala.remote").tpe; + val BeanPropertyAttr = definitions.BeanPropertyAttr; val CloneableClass = definitions.getClass("java.lang.Cloneable"); val RemoteInterface = definitions.getClass("java.rmi.Remote"); @@ -942,7 +943,21 @@ abstract class GenJVM extends SubComponent { (if (sym.isClass || (sym.isModule && !sym.isMethod)) sym.fullNameString('/') else - sym.simpleName.toString().trim()) + suffix; + { + if ( sym.hasFlag(Flags.ACCESSOR) && sym.attributes.exists(a => a match{ + case Pair(BeanPropertyAttr, _) => true + case _ => false + })) + { + if (sym.isSetter) + "set" + nme.setterToGetter(sym.simpleName).toString() + else "get" + sym.simpleName.toString() + } + else { + sym.simpleName.toString() + }.trim() + } + ) + suffix; } def javaNames(syms: List[Symbol]): Array[String] = { diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 228a7cb08b..616070bc29 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -173,7 +173,7 @@ mixin class Definitions requires SymbolTable { // special attributes var SerializableAttr: Type = _; - + var BeanPropertyAttr: Type = _; def getModule(fullname: Name): Symbol = getModuleOrClass(fullname, true); @@ -420,6 +420,7 @@ mixin class Definitions requires SymbolTable { ObjectRefClass = getClass("scala.runtime.ObjectRef"); SerializableAttr = getClass("scala.serializable").tpe; + BeanPropertyAttr = getClass("scala.runtime.compat.BeanProperty").tpe; } } } |