Extension functions + functions type with receivers
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
object AntBuilder() {
|
||||||
|
|
||||||
|
lazy val groovy = library {
|
||||||
|
classpath("$libs/groovy-...")
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy val gant = library {
|
||||||
|
new File("$gantHome/lib").files.each {
|
||||||
|
classpath(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy val JPS = module {
|
||||||
|
targetLevel = "1.5"
|
||||||
|
classpath(antLayout, gant, groovy)
|
||||||
|
src("$projectHome/antLayout/src")
|
||||||
|
}
|
||||||
|
|
||||||
|
}.build()
|
||||||
|
|
||||||
|
class AntBuilder {
|
||||||
|
abstract class ClassPathEntry {}
|
||||||
|
|
||||||
|
class Module : ClassPathEntry {
|
||||||
|
fun classpath(entries : ClassPathEntry...) { ... }
|
||||||
|
var targetLevel : String
|
||||||
|
fun src(src : String) { ... }
|
||||||
|
}
|
||||||
|
|
||||||
|
class Library : ClassPathEntry {
|
||||||
|
fun classpath(entries : ClassPathEntry...) { ... }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun library(initializer : Library.{ => Library}) {
|
||||||
|
val lib = new Library()
|
||||||
|
initializer(lib)
|
||||||
|
return lib
|
||||||
|
}
|
||||||
|
|
||||||
|
fun classpath
|
||||||
|
|
||||||
|
fun module
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/*
|
||||||
class Example(a : Foo, i : Int) : Bar(i), Some {
|
class Example(a : Foo, i : Int) : Bar(i), Some {
|
||||||
// constrtuctors:
|
// constrtuctors:
|
||||||
public this(a : Foo) : this(a, 0)
|
public this(a : Foo) : this(a, 0)
|
||||||
@@ -25,7 +26,7 @@ class Example(a : Foo, i : Int) : Bar(i), Some {
|
|||||||
private set(s : String) { $z = s } // TODO: allow to omit the type here?
|
private set(s : String) { $z = s } // TODO: allow to omit the type here?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// h5. Grammar
|
// h5. Grammar
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ completeExtension
|
|||||||
;
|
;
|
||||||
|
|
||||||
extensionMethod
|
extensionMethod
|
||||||
: accessModifier? "extension" "fun" type "." functionRest
|
: accessModifier? "fun" type "." functionRest
|
||||||
;
|
;
|
||||||
|
|
||||||
extensionProperty
|
extensionProperty
|
||||||
: accessModifier? "extension" propertyRest
|
: accessModifier? propertyModifier? ("val" | "var") type "." propertyRest
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ projectionSpecifier
|
|||||||
;
|
;
|
||||||
|
|
||||||
functionType
|
functionType
|
||||||
: "{" functionTypeContents "}"
|
: (type ".")? "{" functionTypeContents "}"
|
||||||
;
|
;
|
||||||
|
|
||||||
functionTypeContents
|
functionTypeContents
|
||||||
|
|||||||
Reference in New Issue
Block a user