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.295 2003/08/22 00:52:21 nilsson Exp $ + // $Id: master.pike.in,v 1.296 2003/09/08 12:57:33 grubba Exp $      #pike __REAL_VERSION__      // Some programs destroys character pairs beginning with the currency   // symbol when running in chinese locale.   #if "¤/" != "\244/"   #error "master.pike.in is corrupted."   #endif      // --- Some configurable parameters
pike.git/lib/master.pike.in:738:    "%s\n", pname, ext, describe_backtrace(backtrace()) );    }       ret=load_module(fakeroot(fname));    resolv_debug ("low_findprog %s: loaded binary\n", fname);   #endif /* load_module */    }       AUTORELOAD_FINISH(ret,programs,fname);    +  resolv_debug("low_findprog %s: returning %O\n", fname, ret); +     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   // error occurs in the given program. It should remove all references   // to the program so that it can be freed.   //   void unregister(program p)   {    if(string fname=search(programs,p)) { -  +  resolv_debug("unregister %s\n", fname);    programs[fname] = no_value;    // FIXME: The following assumes that programs are always stored    // with '/' as path separators, even on NT. Haven't checked if    // that always is the case.    fname = dirname (fname);    object n;    if ( fname!="" && objectp (n = fc[fname]) )    if (n->is_resolv_dirnode || n->is_resolv_joinnode)    n->delete_value (p);    }
pike.git/lib/master.pike.in:1424:    {    return joined_modules;    }       void _decode (array(object) joined_modules)    {    this_program::joined_modules = joined_modules;    }   };    - object findmodule(string fullname, object|void handler) + program|object findmodule(string fullname, object|void handler)   { -  object o; +  program|object o;       resolv_debug ("findmodule(%O)\n", fullname);    if(!zero_type(o=fc[fullname]) && o != no_value)    { -  if (objectp(o) || o != 0) { +  if (objectp(o) || programp(o) || o != 0) {    resolv_debug ("findmodule(%O) => found %O (cached)\n", fullname, o);    return o;    }    resolv_debug ("findmodule(%O) => not found (cached)\n", fullname);    return UNDEFINED;    }       if(Stat stat=master_file_stat(fakeroot(fullname+".pmod")))    {    if(stat->isdir)
pike.git/lib/master.pike.in:1465:      #if constant(load_module)    if(master_file_stat(fakeroot(fullname+".so"))) {    o = fc[fullname] = low_cast_to_object(fullname, "/.", handler);    DEC_RESOLV_MSG_DEPTH();    resolv_debug ("findmodule(%O) => got .so object %O\n", fullname, o);    return o;    }   #endif    +  if (programp (o = cast_to_program(fullname, "/.", handler))) {    DEC_RESOLV_MSG_DEPTH(); -  +  resolv_debug ("findmodule(%O) => got .pike program %O\n", fullname, o); +  return fc[fullname] = o; +  } +  +  DEC_RESOLV_MSG_DEPTH();    resolv_debug ("findmodule(%O) => not found\n", fullname);    return fc[fullname] = 0;   }      mixed handle_import(string what, string|void current_file, object|void handler)   {    array(string) tmp;    string path;    if(current_file)    {
pike.git/lib/master.pike.in:1536:      //!   class CompatResolver   {    array(string) pike_include_path=({});    array(string) pike_module_path=({});    array(string) pike_program_path=({});    mapping(string:string) predefines = ([]);    string ver;    +  //! If we fail to resolv, try our parent. +  //! +  //! Typical configuration: +  //! @pre{0.6->7.0->7.2->7.4->master@} +  CompatResolver parent_resolver; +     //! The CompatResolver is initialized with a value that can be    //! casted into a "%d.%d" string, e.g. a version object.    void create(mixed version)    {    ver=(string)version;    }       //! Add a directory to search for include files.    //!    //! This is the same as the command line option @tt{-I@}.
pike.git/lib/master.pike.in:1702:    if (identifier == "_static_modules") {    tmp += ({ static_modules });    }       string dir=current_file ? dirname(current_file) : "/";       foreach(pike_module_path, string path)    {    string file=combine_path(dir, path, identifier);    mixed ret = findmodule(file, current_handler); -  if(objectp (ret)) { // ret is either zero or an object here. +  if(objectp (ret) || programp(ret)) { +  // ret is either zero or an object or a program here.    if (ret->is_resolv_dirnode || ret->is_resolv_joinnode) {    if (mixed new_ret = ret->_module_value) {    ret = new_ret;    }    if (ret->is_resolv_joinnode)    tmp += ret->joined_modules;    else    tmp += ({ ret });    } else {    if (mixed new_ret = ret->_module_value) {
pike.git/lib/master.pike.in:1732:    }    }    }    }    if (sizeof(tmp)) {    if (sizeof(tmp) == 1) {    return tmp[0];    }    return joinnode(tmp);    } +  if (parent_resolver) { +  return parent_resolver->resolv(identifier, current_file, +  current_handler); +  }    return UNDEFINED;    }       mapping resolv_cache = set_weak_flag( ([]), 1 );       //!    mixed resolv(string identifier, string|void current_file,    object|void current_handler)    {    resolv_debug("resolv(%O, %O)\n",identifier, current_file);
pike.git/lib/master.pike.in:1795:    return ret;    }       //! This function is called whenever an #include directive is encountered    //! it receives the argument for #include and should return the file name    //! of the file to include    string handle_include(string f,    string current_file,    int local_include)    { -  array(string) tmp; -  string path; -  +     if(local_include)    { -  tmp=EXPLODE_PATH(current_file); +  array(string) tmp=EXPLODE_PATH(current_file);    tmp[-1]=f; -  path=combine_path_with_cwd(tmp*"/"); +  return combine_path_with_cwd(tmp*"/");    }    else    { -  foreach(pike_include_path, path) +  foreach(pike_include_path, string path)    {    path=combine_path(path,f);    if(master_file_stat(fakeroot(path))) -  break; -  else -  path=0; +  return path;    } -  +  if (parent_resolver) { +  return parent_resolver->handle_include(f, current_file, +  local_include);    } -  -  return path; +     } -  +  // Failed. +  return 0; +  }       //!    string read_include(string f)    {    AUTORELOAD_CHECK_FILE(f)    return master_read_file(f);    }       string _sprintf(int t)    {
pike.git/lib/master.pike.in:3582:   //! corresponding to @[Encoder]. See that one for more details.   {    static int unregistered = 1;       object __register_new_program(program p)    {    DEC_MSG ("__register_new_program (%O)\n", p);    if(unregistered && fname)    {    unregistered = 0; +  resolv_debug("register %s\n", fname);    programs[fname]=p;    if (mkobj)    DEC_RETURN (objectp (objects[p]) ? objects[p] : (objects[p]=__null_program()));    }    DEC_RETURN (0);    }       static mixed thingof (string|array what)    {    mixed res;
pike.git/lib/master.pike.in:3803:    }   }      //! Version information about the current Pike version.   Version currentversion=Version(__MAJOR__,__MINOR__);      mapping(Version:CompatResolver) compat_handler_cache=set_weak_flag( ([]), 1);      CompatResolver get_compilation_handler(int major, int minor)   { -  CompatResolver ret; -  +     Version v=Version(major,minor);       if(v > currentversion)    {    /* do we want to make an error if major.minor > __MAJOR__.__MINOR ? */    return 0;    }    -  +  CompatResolver ret; +     if(!zero_type(ret=compat_handler_cache[v])) return ret;    -  array files; +  array(string) files;    array(Version) available=({});      #if "¤share_prefix¤"[0]!='¤'    if (!(files = get_dir("¤share_prefix¤"))) {    werror ("Error listing directory %O: %s\n",    "¤share_prefix¤", strerror (errno()));    files = ({});    }    foreach(files, string ver)    {
pike.git/lib/master.pike.in:3873:    {    compat_handler_cache[v]=0;    return 0;    }       /* Same as available[0] */    if(ret=compat_handler_cache[available[0]])    return compat_handler_cache[v]=ret;   #endif    -  ret=CompatResolver(v); -  /* Add default paths */ -  ret->pike_module_path=pike_module_path; -  ret->pike_include_path=pike_include_path; +  // The root resolver is this object. +  ret = this_object();       foreach(reverse(available), Version tmp)    { -  +  CompatResolver compat_handler = compat_handler_cache[tmp]; +  if (!compat_handler) { +  compat_handler = CompatResolver(tmp); +  +  // Fall back to the successor version. +  compat_handler->parent_resolver = ret; +     string base;   #if "¤lib_prefix¤"[0]!='¤'    base=combine_path("¤lib_prefix¤",sprintf("%s",tmp)); -  ret->add_module_path(combine_path(base,"modules")); -  ret->add_include_path(combine_path(base,"include")); +  compat_handler->add_module_path(combine_path(base,"modules")); +  compat_handler->add_include_path(combine_path(base,"include"));   #endif      #if "¤share_prefix¤"[0]!='¤'    base=combine_path("¤share_prefix¤",sprintf("%s",tmp)); -  ret->add_module_path(combine_path(base,"modules")); -  ret->add_include_path(combine_path(base,"include")); +  compat_handler->add_module_path(combine_path(base,"modules")); +  compat_handler->add_include_path(combine_path(base,"include"));   #endif -  } +     -  if( v <= Version(0,6)) +  if( tmp <= Version(0,6))    ret->pike_module_path+=({"."});    -  compat_handler_cache[v] = ret; -  +    #ifndef RESOLVER_HACK -  compat_handler_cache[available[0]] = ret; /* may be equal to 'v' */ +  ret = compat_handler_cache[tmp] = compat_handler;   #endif -  +  } +  }    -  +  // Note: May duplicate the assignment above. +  compat_handler_cache[v] = ret; +     return ret;   }      string _sprintf(int t)   {    switch(t) {    case 't': return "master";    case 'O': return "master()";    }   }