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.395 2007/06/13 13:30:51 mbaehr Exp $ + // $Id: master.pike.in,v 1.396 2007/06/13 14:25:30 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:355:    program ret = compile(cpp(source, filename||"-", 1, handler,    compat_major, compat_minor,    (zero_type(_show_if_constant_errors)?    show_if_constant_errors:    _show_if_constant_errors)),    handler,    compat_major,    compat_minor,    p,    o); -  cache_source(ret, source); +  if (source_cache) +  source_cache[ret] = source;    return ret;   }      //!   string master_read_file(string file)   {    object o=Files()->Fd();    if( ([function(string, string : int)]o->open)(fakeroot(file),"r") )    return ([function(void : string)]o->read)();    return 0;
pike.git/lib/master.pike.in:595:   //! @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) documentation = ([]); + mapping(program:string) source_cache;      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:749:   {    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 source) - { -  if (documentation && !documentation[ret]) -  documentation[ret] = ([ "source":source ]); - } -  +    //! Find the files in which @[mod] is defined, as they may be hidden away in   //! joinnodes and dirnodes   //!   //! @param mod   //! The module we are looking for.   //!   //! @returns   //! An array of strings with filenames.   //! (one for each file in a joinnode, or just one otherwise)   array(string) module_defined(object mod)
pike.git/lib/master.pike.in:785:    foreach (mods;; object mod)    {    if (mod->is_resolv_dirnode)    files += ({ Builtin()->program_defined(object_program(mod->module)) });    else    files += ({ Builtin()->program_defined(object_program(mod)) });    }    return files;   }    + //! Enable caching of sources from compile_string() + void enable_source_cache() + { +  source_cache = ([]); + } +    //! 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; -  string fname; +        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);    }    -  fname = Builtin()->program_defined(prog); +     -  if (doc_extractor && (!documentation[prog] || !documentation[prog]->doc)) +  if (!documentation[prog] && doc_extractor)    { -  documentation[prog] = ([ "doc":doc_extractor(documentation[prog]->source||master_read_file(fname)||"", sprintf("%O", prog)) ]); +  string source; +  if (!source_cache || !source_cache[prog]) +  source = master_read_file(Builtin()->program_defined(prog)); +  else +  source = source_cache[prog]; +  if (source) +  { +  catch +  { +  documentation[prog] = doc_extractor(source, sprintf("%O", prog)); +  }; +  //FIXME: handle this error somehow    } -  +  }    -  if (documentation[prog] && documentation[prog]->doc) +  if (documentation[prog])    {    if (child) -  return documentation[prog]->doc->findObject(child); +  return documentation[prog]->findObject(child);    else -  return documentation[prog]->doc; +  return documentation[prog];    }   }         static program low_findprog(string pname,    string ext,    object|void handler,    void|int mkobj)   {    program ret;