summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bind/AutoBinder.kt17
-rw-r--r--src/bind/LispBinding.kt4
2 files changed, 21 insertions, 0 deletions
diff --git a/src/bind/AutoBinder.kt b/src/bind/AutoBinder.kt
index 6d2cac2..648aaef 100644
--- a/src/bind/AutoBinder.kt
+++ b/src/bind/AutoBinder.kt
@@ -22,6 +22,22 @@ class AutoBinder {
return null
}
+ private fun mapForeignObject(parameter: Parameter): ObjectMapper? {
+ parameter.getAnnotation(UnmapForeignObject::class.java) ?: return null
+ return { a, b, c, d ->
+ when (val x = a()) {
+ is LispData.ForeignObject<*> -> {
+ parameter.effectiveType.cast(x.obj)
+ }
+
+ else -> {
+ c.reportError("$x needs to be of type")
+ null
+ }
+ }
+ }
+ }
+
private fun mapErrorReporter(parameter: Parameter): ObjectMapper? {
if (ErrorReporter::class.java.isAssignableFrom(parameter.effectiveType)) return { a, b, c, d -> c }
return null
@@ -95,6 +111,7 @@ class AutoBinder {
::mapString,
::mapBoolean,
::mapAST,
+ ::mapForeignObject,
)
diff --git a/src/bind/LispBinding.kt b/src/bind/LispBinding.kt
index 7af0e67..2a4c688 100644
--- a/src/bind/LispBinding.kt
+++ b/src/bind/LispBinding.kt
@@ -5,3 +5,7 @@ package moe.nea.lisp.bind
annotation class LispBinding(
val name: String,
)
+
+@Retention(AnnotationRetention.RUNTIME)
+@Target(AnnotationTarget.VALUE_PARAMETER)
+annotation class UnmapForeignObject