remove unregistration change
This commit is contained in:
parent
075b45768f
commit
936e4ccdc2
19
functions.go
19
functions.go
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user