func (ir *interpreter) unregister_commands(name string) error { if _, ok := ir.methods[name]; !ok { return errors.New("gothic: trying to unregister a non-existent method set") } val := ir.methods[name] t := reflect.TypeOf(val) for i, n := 0, t.NumMethod(); i < n; i++ { m := t.Method(i) if !strings.HasPrefix(m.Name, "TCL") { continue } subname := m.Name[3:] if strings.HasPrefix(m.Name, "TCL_") { subname = m.Name[4:] } cname := C.CString(name + "::" + subname) status := C.Tcl_DeleteCommand(ir.C, cname) C.free(unsafe.Pointer(cname)) if status != C.TCL_OK { return errors.New(C.GoString(C.Tcl_GetStringResult(ir.C))) } } delete(ir.methods, name) for _, id := range ir.method_handles[name] { ir.handles.free_handle(id) } delete(ir.method_handles, name) return nil }
func (ir *Interpreter) UnregisterChannel(name string) { if _, ok := ir.channels[name]; !ok { return } cname := C.CString(name) status := C.Tcl_DeleteCommand(ir.C, cname) C.free_string(cname) if status != C.TCL_OK { panic(C.GoString(C.Tcl_GetStringResult(ir.C))) } }
func (ir *interpreter) unregister_command(name string) error { if _, ok := ir.commands[name]; !ok { return errors.New("gothic: trying to unregister a non-existent command") } cname := C.CString(name) status := C.Tcl_DeleteCommand(ir.C, cname) C.free(unsafe.Pointer(cname)) if status != C.TCL_OK { return errors.New(C.GoString(C.Tcl_GetStringResult(ir.C))) } return nil }