pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   // -*- Pike -*-   //   // Master Control Program for Pike.   //   // This file is part of Pike. For copyright information see COPYRIGHT.   // Pike is distributed under GPL, LGPL and MPL. See the file COPYING   // for more information.   // - // $Id: master.pike.in,v 1.392 2007/06/02 10:23:15 grubba Exp $ + // $Id: master.pike.in,v 1.393 2007/06/11 14:24:57 mbaehr Exp $      #pike __REAL_VERSION__   //#pragma strict_types      // Some programs destroys character pairs beginning with the currency   // symbol when running in chinese locale.   #if "ยค/" != "\244/"   #error "master.pike.in is corrupted."   #endif   
pike.git/lib/master.pike.in:593:   //! @mapping   //! @member program filename   //! @endmapping   //! The filename path separator is / on both NT and UNIX.   //!   //! @note   //! Special cases: The current master program is available under the   //! name @expr{"/master"@}, and the program containing the @[main]   //! function under @expr{"/main"@}.   mapping(string:program|NoValue) programs=(["/master":this_program]); + mapping(program:mapping|object) documentation = ([]);      mapping (program:object|NoValue) objects=([    this_program : this,    object_program(_static_modules): _static_modules   ]);      mapping(string:object|NoValue) fc=([]);      // Note: It's assumed that the mappings above never decrease in size   // unless the reverse mappings above also are updated. no_value should
pike.git/lib/master.pike.in:746:   {    fname = FIX_CASE(fname);    if (has_suffix(fname, ".pmod")) return 3;    if (has_suffix(fname, ".so")) return 2;    if (has_suffix(fname, ".pike")) return 1;       // FIXME: Warn here?    return 0;   }    + //! Used to capture the source from programs being compiled to allow later + //! extraction of documentation + static void cache_source(mixed ret, string fname, void|string source) + { +  if (documentation && !documentation[ret]) +  documentation[ret] = ([ "fname":fname, "source":source ]); + } +  + //! Show documentation for the item @[obj] + //! + //! @param obj + //! The object for which the documentation should be shown + //! + //! @returns + //! an AutoDoc object + object show_doc(program|object|function obj) + { +  object doc_extractor = main_resolv("Tools.AutoDoc.PikeExtractor.extractClass"); +  string child; +  program prog; +  if (programp(obj)) +  prog = obj; +  if (functionp(obj)) +  { +  prog = function_program(obj); +  child = (describe_function(obj)/"->")[-1]; +  } +  if (objectp(obj)) +  { +  if (obj->is_resolv_joinnode) +  obj = obj->joined_modules[0]; // FIXME: check for multiples +  if (obj->is_resolv_dirnode) +  prog = object_program(obj->module); +  } +  +  if (doc_extractor && documentation[prog] && !documentation[prog]->doc) +  { +  documentation[prog]->doc = doc_extractor(documentation[prog]->source||master_read_file(documentation[prog]->fname)||"", sprintf("%O", prog)); +  documentation[prog]->source = 0; // source not needed once anymore +  } +  if (documentation[prog] && documentation[prog]->doc) +  { +  if (child) +  return documentation[prog]->doc->findObject(child); +  else +  return documentation[prog]->doc; +  } + } +  +    static program low_findprog(string pname,    string ext,    object|void handler,    void|int mkobj)   {    program ret;    Stat s;    string fname=pname+ext;       resolv_debug("low_findprog(%O, %O, %O, %O)\n",
pike.git/lib/master.pike.in:799:   #endif       if( (s=master_file_stat(fakeroot(fname))) && s->isreg )    {   #ifdef PIKE_AUTORELOAD    if(!autoreload_on || load_time[fname] >= s->mtime)   #endif    {    if(!zero_type (ret=programs[fname]) && ret != no_value) {    resolv_debug ("low_findprog %s: returning cached (no autoreload)\n", fname); +  cache_source(ret, fname);    return ret;    }    }       AUTORELOAD_BEGIN();      #ifdef PIKE_AUTORELOAD    if (load_time[fname] >= s->mtime)    if (!zero_type (ret=programs[fname]) && ret != no_value) {    resolv_debug ("low_findprog %s: returning cached (autoreload)\n", fname); -  +  cache_source(ret, fname);    return ret;    }   #endif       switch(ext)    {    case "":    case ".pike":    foreach(query_precompiled_names(fname), string oname) {    if(Stat s2=master_file_stat(fakeroot(oname)))
pike.git/lib/master.pike.in:838:    get_codec)(fname, mkobj, handler));    DEC_RESOLV_MSG_DEPTH();    resolv_debug ("low_findprog %s: dump decode ok\n", fname);    if (ret && ret->this_program_does_not_exist) {    resolv_debug ("low_findprog %s: program claims not to exist\n",    fname);    return programs[fname] = 0;    }    else {    resolv_debug("low_findprog %s: returning %O\n", fname, ret); +  cache_source(ret, fname);    return programs[fname]=ret;    }    };    DEC_RESOLV_MSG_DEPTH();    resolv_debug ("low_findprog %s: dump decode failed\n", fname);    programs[fname] = no_value;    call_compile_warning (handler, oname,    "Decode failed: " + describe_error(err));    } else if (out_of_date_warning) {    call_compile_warning (handler, oname,
pike.git/lib/master.pike.in:879:    } )    {    DEC_RESOLV_MSG_DEPTH();    resolv_debug ("low_findprog %s: compilation failed\n", fname);    objects[ret] = no_value;    ret=programs[fname]=0; // Negative cache.    throw(e);    }    DEC_RESOLV_MSG_DEPTH();    resolv_debug ("low_findprog %s: compilation ok\n", fname); +  cache_source(ret, fname, src);    break;      #if constant(load_module)    case ".so":    if (fname == "") {    werror( "low_findprog(%O, %O) => load_module(\"\")\n"    "%s\n", pname, ext, describe_backtrace(backtrace()) );    }       if (array|object err = catch (ret = load_module(fakeroot(fname)))) {
pike.git/lib/master.pike.in:921:    }       AUTORELOAD_FINISH(ret,programs,fname);       if (ret && ret->this_program_does_not_exist) {    resolv_debug ("low_findprog %s: program says it doesn't exist\n", fname);    return programs[fname] = 0;    }    else {    resolv_debug("low_findprog %s: returning %O\n", fname, ret); +  cache_source(ret, fname);    return programs[fname]=ret;    }    }       resolv_debug ("low_findprog %s: file not found\n", fname);    return 0;   }      //   // This function is called by the compiler when a delayed compilation
pike.git/lib/master.pike.in:1009:    ext="."+reverse(ext);    pname=pname[..<sizeof(ext)];    }    else {    ext="";    }       if(IS_ABSOLUTE_PATH(pname))    {    program|NoValue prog = programs[pname]; -  if ((!zero_type(prog)) && (prog != no_value)) return prog; +  if ((!zero_type(prog)) && (prog != no_value)) +  { +  cache_source(prog, pname); +  return prog; +  }    pname=combine_path("",pname);    return findprog(pname,ext,handler,mkobj);    }    else {    string cwd;    if(current_file)    {    cwd=dirname(current_file);    }    else {