This PR fixes some pretty bad memory leaks. Somewhere along the line a bad assumption was made that memcpy had to be used instead of just storing the value. While just storing the value does work for module builds, because of how GDExtension works it cant really handle a null Variant. This is because all variants even null ones point to a Variant in the engine its self. Thus when we assign a real value to a null variant it causes a memory exception. For this reason memmove was used instead. As a safe way to transfer the value to lua. The ref count is also incremented for RefCounted's when passed to lua. And de incremented in the lua gc.
The configure_gc method has also been added. It is a direct exposure of lua_gc from the C API.
This PR fixes some pretty bad memory leaks. Somewhere along the line a bad assumption was made that memcpy had to be used instead of just storing the value. While just storing the value does work for module builds, because of how GDExtension works it cant really handle a null Variant. This is because all variants even null ones point to a Variant in the engine its self. Thus when we assign a real value to a null variant it causes a memory exception. For this reason memmove was used instead. As a safe way to transfer the value to lua. The ref count is also incremented for RefCounted's when passed to lua. And de incremented in the lua gc.
The configure_gc method has also been added. It is a direct exposure of lua_gc from the C API.