[Turn off line numbering]
1: arg @destroyed;
2: var a, v, d, definer, method, descendants, str, tb;
3:
4: (> .perms(caller(), $root, $sys) <);
5: destroyed = destroyed ? 1 : 0;
6: descendants = .descendants() + [this()];
7:
8: // call [ancestors...].uninit_ancestor() on the object being destroyed
9: for a in (ancestors()) {
10: method = tosym("uninit_" + a.objname());
11: if ((definer = (| find_method(method) |))) {
12: if (definer != a) {
13: // scream madly and run around--everybody should know this
14: str = "UNINIT ERROR: uninit method for " + a;
15: str += " in wrong place (" + definer + ")";
16: (| definer.manager().tell(str) |);
17: (| a.manager().tell(str) |);
18: (| sender().tell(str) |);
19: continue;
20: }
21: catch any {
22: .(method)();
23: } with {
24: // try and let somebody know they made a boo-boo somewhere
25: tb = traceback().fmt_tb();
26: str = "UNINIT ERROR " + this() + "<" + definer + ">:";
27: if (definer) {
28: (| definer.manager().tell(str) |);
29: (| definer.manager().tell(tb) |);
30: }
31: (| sender().tell(str) |);
32: (| sender().tell(tb) |);
33: (| sender().tell("Continuing uninit..") |);
34: (| $sys.log_traceback(tb, "** " + str) |);
35: }
36: }
37: refresh();
38: }
39:
40: // if we have descendants, clean anything from the object being dested
41: method = tosym("uninit_" + .objname());
42: if ((definer = (| find_method(method) |))) {
43: if (definer != this()) {
44: // scream madly and run around--everybody should know this
45: str = "UNINIT ERROR: uninit method for " + a;
46: str += " in wrong place (" + definer + ")";
47: (| definer.manager().tell(str) |);
48: (| .manager().tell(str) |);
49: (| sender().tell(str) |);
50: } else {
51: for d in (descendants) {
52: catch any {
53: d.(method)();
54: } with {
55: // try and let somebody know they made a boo-boo somewhere
56: str = "UNINIT ERROR " + d + "<" + this() + ">:";
57: tb = traceback().fmt_tb();
58: (| .manager().tell(str) |);
59: (| .manager().tell(tb) |);
60: if (.manager() != sender()) {
61: (| sender().tell(str) |);
62: (| sender().tell(tb) |);
63: }
64: (| sender().tell("Continuing uninit..") |);
65: (| $sys.log_traceback(tb, "** " + str) |);
66: }
67: refresh();
68: }
69: }
70: }
71:
72: // clear vars
73: if (!destroyed && descendants)
74: $sys.clear_definer_vars(this(), descendants);
["// Created as a part of ColdCore, see: @help Credit"]