remove unregistration change

This commit is contained in:
Sky Johnson 2025-03-27 14:04:17 -05:00
parent 075b45768f
commit 936e4ccdc2

View File

@ -90,25 +90,6 @@ func (s *State) RegisterGoFunction(name string, fn GoFunction) error {
// UnregisterGoFunction removes a global function
func (s *State) UnregisterGoFunction(name string) {
// First, find the function to get its pointer
s.GetGlobal(name)
if s.IsFunction(-1) {
// Get the first upvalue (function pointer)
if C.lua_getupvalue(s.L, -1, 1) != nil {
ptr := C.lua_touserdata(s.L, -1)
if ptr != nil {
// Remove from registry
functionRegistry.Lock()
delete(functionRegistry.funcs, ptr)
C.free(ptr)
functionRegistry.Unlock()
}
s.Pop(1) // Pop upvalue
}
}
s.Pop(1) // Pop function or nil
// Remove global
s.PushNil()
s.SetGlobal(name)
}