Anaminus / rbxmk

A tool for processing Roblox files.
MIT License
109 stars 11 forks source link

clipboard.write cannot encode non-variant types #50

Open Anaminus opened 3 years ago

Anaminus commented 3 years ago

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.