Fix using g-i introspected function as callback
This is basically a revert of commit 7140cac8, although so much has changed in the meantime that none of the revert applied cleanly, so it's more of an "un-rewrite". This fixes a regression that has been present for almost exactly 4 years.
Storing a JSFunction* pointer in closures did not take into account the fact that not all callable JSObjects have an associated JSFunction. They could be exotic objects with a [[Call]] method. In particular, introspected functions are this, so this prevented g-i function objects from being used as signal handlers.
(Less importantly, the same probably applied to callable Proxy objects.)
Also adds a regression test so that this doesn't happen again.
Closes: #518 (closed)