[Turn off line numbering]1: arg header, info, args; 2: var ref, str_ref, name, obj, code, def, out, line, linenumbers, user, strings, flags, trace, anc, current, m, options; 3: 4: ref = (| args["target"] |); 5: linenumbers = (| args["linenumbers"] |); 6: if (!("linenumbers" in args['arg_list])) { 7: if ($security_lib.check_userdb_with_optional(header['interface])) { 8: user = header['interface].get_info('run_as); 9: linenumbers = (| user.get_setting("www-show-line-num", $www_preferences) |) || 0; 10: } 11: } 12: catch any { 13: name = (> tosym(ref[4]) <); 14: obj = ref[3]; 15: def = obj.find_method(name); 16: if ('native in def.method_flags(name)) 17: code = ["This method is implemented natively within the driver."]; 18: else 19: code = def.list_method(name).mmap('html_escape); 20: options = "linenumbers" in args['arg_list] && linenumbers ? [["linenumbers", "yes"]] : []; 21: code = $code_lib.code_to_html(code, obj, options); 22: if (linenumbers) 23: code = code.numbered_text(); 24: str_ref = obj + "." + name + "()"; 25: out = .build_header(header, info, args, #[['title, str_ref]]) + ["<h1>Method code for " + ._make_string_to_display_href(obj, "&methods=yes") + (def != obj ? "<" + ._make_string_to_display_href(def, "&methods=yes") + ">" : "") + "." + name + "()" + "</h1>", "<blockquote>"]; 26: strings = linenumbers ? ["no", "off"] : ["yes", "on"]; 27: out += [strfmt("[<A HREF=\"/bin/method?target=%s&linenumbers=%s\">Turn %s line numbering</A>]", str_ref, @strings)]; 28: out += ["<hr size=1 noshade width=\"50%\" align=left><pre>"]; 29: out += code + ["</pre><hr size=1 noshade width=\"50%\" align=left>"]; 30: line = "// " + def.credit().join("<br>// "); 31: out += ["<font color=\"#a0a0a0\">" + line + "</font>"]; 32: out += ["</blockquote>"]; 33: strings = (trace = []); 34: current = def; 35: while (current) { 36: trace += [current]; 37: current = (| def.find_next_method(name, current) |); 38: } 39: if (trace.length() > 1) { 40: out += ["<h2>Method Ancestry Override:</h2>"]; 41: out += ["<blockquote><pre>"]; 42: for anc in (trace) { 43: m = anc.method_info(name); 44: out += [strfmt("%5l %4r " + ._make_string_to_display_href(anc) + ._make_method_href([anc, name, m[1]], @options), $object_lib.parse_method_flags(m[6]), m[4])]; 45: } 46: out += ["</pre></blockquote>"]; 47: } 48: } with { 49: switch (error()) { 50: case ~type: 51: return [header['interface].response(400, "Invalid method reference " + obj + "." + name + "()")]; 52: case ~methodnf: 53: line = obj + "." + name + "()"; 54: return [header['interface].response(400, line + " not found.")]; 55: default: 56: return [header['interface].response(400, traceback()[1][2])]; 57: } 58: } 59: return [out + .build_footer(header, info, args)];
// Brad Roberts
// Bruce Mitchener, Jr.
// Created 16-May-1997 as a part of ColdCore, see: @help Credit