[Turn off line numbering]1: var ancestors, pos, len, method, a, def, str, tb; 2: 3: // called by $sys.create() to create a new object. 4: if (caller() != $sys && sender() != this()) 5: throw(~perm, "Caller is not $sys and sender is not this."); 6: if (inited) 7: throw(~perm, "Already initialized."); 8: ancestors = ancestors().reverse(); 9: for a in (ancestors) { 10: refresh(); 11: if (!(method = (| tosym("init_" + tostr(a.objname())) |))) 12: continue; 13: if ((def = (| find_method(method) |))) { 14: if (def != a) { 15: (| def.manager().tell("Initialization method for " + a + " in wrong place (" + find_method(method) + ")") |); 16: } else { 17: catch any { 18: .(method)(); 19: } with { 20: // try and let somebody know they made a boo-boo somewhere 21: str = "UNINIT ERROR " + this() + "<" + def + ">:"; 22: tb = traceback().fmt_tb(); 23: if (def) { 24: (| def.manager().tell(str) |); 25: (| def.manager().tell(tb) |); 26: } 27: if (.manager() != sender()) { 28: (| sender().tell(str) |); 29: (| sender().tell(tb) |); 30: } 31: (| sender().tell("Continuing init..") |); 32: (| $sys.log_traceback(tb, "** " + str) |); 33: } 34: } 35: } 36: } 37: inited = 1;
// Created as a part of ColdCore, see: @help Credit