Certain formats specify EncodeTypes, allowing them to encode types that don't work with Variant (e.g. Objects, DescActions). Writing to the clipboard involves a number of format selectors, but only one value, which is pulled as a Variant. This causes the clipboard to fail on these non-variant types. In order to properly handle this, pulling the value must delayed so that each format selector can interpret the value in its own way.
Currently, the clipboard implementation is independent of the reflection layer (ClipboardSource) to provide a generic API usable by anything. An implementation that retains ClipboardSource would involve extracting the Lua stack to a []lua.LValue and passing it to ClipboardSource.Write.
The easier option would be to remove ClipboardSource entirely, and move the implementation back into the clipboard library functions. So far, I don't really see a use for having a reflection-independent implementation anyway. Notably, ClipboardSource isn't used anywhere else except the clipboard library. It also has a dependency on World, but only to get registered Formats and the world's Global for passing to Formats.
Certain formats specify EncodeTypes, allowing them to encode types that don't work with Variant (e.g. Objects, DescActions). Writing to the clipboard involves a number of format selectors, but only one value, which is pulled as a Variant. This causes the clipboard to fail on these non-variant types. In order to properly handle this, pulling the value must delayed so that each format selector can interpret the value in its own way.
Currently, the clipboard implementation is independent of the reflection layer (ClipboardSource) to provide a generic API usable by anything. An implementation that retains ClipboardSource would involve extracting the Lua stack to a
[]lua.LValue
and passing it to ClipboardSource.Write.The easier option would be to remove ClipboardSource entirely, and move the implementation back into the clipboard library functions. So far, I don't really see a use for having a reflection-independent implementation anyway. Notably, ClipboardSource isn't used anywhere else except the clipboard library. It also has a dependency on World, but only to get registered Formats and the world's Global for passing to Formats.