summaryrefslogtreecommitdiff
path: root/src/bind/AutoBinder.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/bind/AutoBinder.kt')
-rw-r--r--src/bind/AutoBinder.kt17
1 files changed, 17 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,
)