The definition of a new GUIProxy type currently leads to a lot of duplicated code.
This changes a few things to reduce that:
- Store the functions in an unordered_map. I actually have a templated implementation that's equivalent to the current c++ ifs, but tbh it's kind of ugly, I think it'll be better once we hit c++20. The performance impact is likely not too bad anyways.
- Clean up CreateJSObject by making it simpler and less error prone (as it's basically 100% copy paste now). I'm considering making it a macro. Unfortunately, we still need this.
- Move more things into the _impl.h
- Clear out the un-necessary friends declaration in the specific types by moving the functions to the public interface, which makes sense.
It also fixes a memory leak, as I wasn't actually destroying the persistent rooted. This is now done.
This doesn't change what one needs to do to add a new type, but it does reduce the actual code that's necessary, and makes it less error prone.