-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a55185c
commit 4452b54
Showing
10 changed files
with
157 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
7 changes: 7 additions & 0 deletions
7
kapshot-runtime/src/main/kotlin/io/koalaql/kapshot/Capturable.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.koalaql.kapshot | ||
|
||
interface Capturable<T : Capturable<T>> { | ||
fun source(): String = error("there is no source code for this block") | ||
|
||
fun withSource(source: String): T | ||
} |
8 changes: 6 additions & 2 deletions
8
kapshot-runtime/src/main/kotlin/io/koalaql/kapshot/CapturedBlock.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
package io.koalaql.kapshot | ||
|
||
fun interface CapturedBlock<T> { | ||
fun interface CapturedBlock<T>: Capturable<CapturedBlock<T>> { | ||
operator fun invoke(): T | ||
|
||
fun source(): String = error("there is no source code for this block") | ||
override fun withSource(source: String): CapturedBlock<T> { | ||
return object : CapturedBlock<T> by this { | ||
override fun source(): String = source | ||
} | ||
} | ||
} |
6 changes: 2 additions & 4 deletions
6
kapshot-runtime/src/main/kotlin/io/koalaql/kapshot/CapturedBlocks.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
package io.koalaql.kapshot | ||
|
||
fun <T> addSourceToBlock(block: CapturedBlock<T>, source: String): CapturedBlock<T> = object : CapturedBlock<T> { | ||
override fun invoke(): T = block() | ||
override fun source(): String = source | ||
} | ||
fun <T : Capturable<T>> addSourceToBlock(block: Capturable<T>, source: String): T = | ||
block.withSource(source) |
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
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
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