diff options
author | nea <nea@nea.moe> | 2023-08-22 12:39:32 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-08-22 12:39:32 +0200 |
commit | 2904a9a9bd4f4ed7681ebd1c821401020a6118c7 (patch) | |
tree | 42911e665bb4e130824747e2e1e100b36f1a82b9 /src/bind/AutoBinder.kt | |
parent | 39f1849edcaa9005814525cd13f76a5daaa15ae0 (diff) | |
download | nealisp-2904a9a9bd4f4ed7681ebd1c821401020a6118c7.tar.gz nealisp-2904a9a9bd4f4ed7681ebd1c821401020a6118c7.tar.bz2 nealisp-2904a9a9bd4f4ed7681ebd1c821401020a6118c7.zip |
Opaque foreign object mapping
Diffstat (limited to 'src/bind/AutoBinder.kt')
-rw-r--r-- | src/bind/AutoBinder.kt | 17 |
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, ) |