pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   /* -*- Pike -*-    * -  * $Id: master.pike.in,v 1.146 2001/04/07 00:31:00 nilsson Exp $ +  * $Id: master.pike.in,v 1.147 2001/05/31 00:14:21 grubba Exp $    *    * Master-file for Pike.    *    * Based on master.pike 1.67.    */      // Some configurable parameters useful for debugging      #pike __REAL_VERSION__   #define PIKE_AUTORELOAD
pike.git/lib/master.pike.in:646:    * previous_object(), can be virtually anything in this function, as it    * is called from the compiler.    */   program handle_inherit(string pname, string current_file, object|void handler)   {    return cast_to_program(pname, current_file, handler);   }      mapping (program:object) objects=([object_program(this_object()):this_object()]);    - object low_cast_to_object(string oname, string current_file) + object low_cast_to_object(string oname, string current_file, +  object|void current_handler)   {    program p;    object o;    -  p=cast_to_program(oname, current_file); +  p = cast_to_program(oname, current_file, current_handler);    if(!p) return 0;    if(!(o=objects[p])) o=objects[p]=p();    return o;   }      /* This function is called when the drivers wants to cast a string    * to an object because of an implict or explicit cast. This function    * may also receive more arguments in the future.    */   object cast_to_object(string oname, string current_file)   {    if(object o=low_cast_to_object(oname, current_file))    return o;    error("Cast '"+oname+"' to object failed"+    ((current_file && current_file!="-")?sprintf(" for '%s'",current_file):"")+".\n");    return 0;   }    - class dirnode + class dirnode(string dirname, object|void handler)   {    constant is_resolv_dirnode = 1; -  string dirname; +     mixed module=module_checker();    mapping(string:mixed) cache=([]);    array(string) files;    -  void create(string name) -  { -  dirname=name; -  } -  +     class module_checker    {    int `!()    {    module=0; -  if(module=findmodule(dirname+"/module")) +  if(module=findmodule(dirname+"/module", handler))    if(mixed tmp=module->_module_value)    module=tmp;    return !module;    }       mixed `[](string index) { if(module) return module[index]; }    array(string) _indices() { if(module) return indices(module); }    array _values() { if(module) return values(module); }    }   
pike.git/lib/master.pike.in:722:    {    if( search(s, index)!=-1 || search(index,s)!=-1 )    {    ret=1;    break;    }    }    if(!ret)    return UNDEFINED;    index = dirname+"/"+index; -  if(object o=findmodule(index)) +  if(object o=findmodule(index, handler))    {    if(mixed tmp=o->_module_value) o=tmp;    return o;    } -  if (program p=cast_to_program( index, 0 )) return p; +  if (program p=cast_to_program( index, 0, handler )) return p;    return UNDEFINED;    }       mixed `[](string index)    {    mixed ret;    if(!zero_type(ret=cache[index]))    {    // The check below is to (hopefully) avoid calling any function    // in ret (like `! or `==) in case it's an object.
pike.git/lib/master.pike.in:901:    {    fill_cache();    return values(cache);    }   };      // Variables mustn't be static to allow for replace_master().   // /grubba 1998-04-10   mapping(string:mixed) fc=([]);    - object findmodule(string fullname) + object findmodule(string fullname, object|void handler)   {    object o;    if(!zero_type(o=fc[fullname]))    {    return o;    }       if(Stat stat=master_file_stat(fakeroot(fullname+".pmod")))    {    if(stat[1]==-2) -  return fc[fullname]=dirnode(fullname+".pmod"); +  return fc[fullname]=dirnode(fullname+".pmod", handler);    }    -  if(o=low_cast_to_object(fullname+".pmod","/.")) +  if(o = low_cast_to_object(fullname+".pmod", "/.", handler))    return fc[fullname]=o;      #if constant(load_module)    if(master_file_stat(fakeroot(fullname+".so"))) -  return fc[fullname]=low_cast_to_object(fullname,"/."); +  return fc[fullname] = low_cast_to_object(fullname, "/.", handler);   #endif -  +     return fc[fullname]=UNDEFINED;   }      mixed handle_import(string what, string|void current_file, object|void handler)   {    array(string) tmp;    string path;    if(current_file)    {    tmp=EXPLODE_PATH(current_file);    tmp[-1]=what;    path=combine_path_with_cwd( tmp*"/");    } -  +  if (handler) { +  return dirnode(path, handler); +  }    return fc[path]=dirnode(path);   }            multiset no_resolv = (<>);   class CompatResolver   {    array(string) pike_include_path=({});    array(string) pike_module_path=({});
pike.git/lib/master.pike.in:1073:    mixed err =catch {    if(x=resolv("__default.all_constants")) x=x();    };       compat_major=saved_compat_major;    compat_minor=saved_compat_minor;    if(err) throw(err);    return x;    }    -  mixed resolv_base(string identifier, string|void current_file) +  mixed resolv_base(string identifier, string|void current_file, +  object|void current_handler)    {    array(mixed) tmp = ({});    string dir=current_file ? dirname(current_file) : "/";    foreach(pike_module_path, string path)    { -  string file=combine_path(dir ,path,identifier); -  if(mixed ret=findmodule(file)) { +  string file = combine_path(dir, path, identifier); +  if(mixed ret = findmodule(file, current_handler)) {    if ((objectp(ret)) &&    (ret->is_resolv_dirnode || ret->is_resolv_joinnode)) {    if (mixed new_ret = ret->_module_value) {    ret = new_ret;    }    tmp += ({ ret });    } else {    if (mixed new_ret = ret->_module_value) {    ret = new_ret;    }
pike.git/lib/master.pike.in:1112:    if (sizeof(tmp)) {    if (sizeof(tmp) == 1) {    return(tmp[0]);    }    return joinnode(tmp);    }    return UNDEFINED;    }       mapping resolv_cache = set_weak_flag( ([]), 1 ); -  mixed resolv(string identifier, string|void current_file) +  mixed resolv(string identifier, string|void current_file, +  object|void current_handler)    { -  +  // FIXME: Support having the cache in the handler?    if( no_resolv[ identifier ] )    return UNDEFINED;       mixed ret;    string id=identifier+":"+(current_file ? dirname(current_file) : "-");    if( !zero_type (ret = resolv_cache[id]) )    return ret == ZERO_TYPE ? UNDEFINED : resolv_cache[id];    array(string) tmp=identifier/"."; -  ret=resolv_base(tmp[0],current_file); +  ret = resolv_base(tmp[0], current_file, current_handler);    foreach(tmp[1..],string index) ret=ret[index];    resolv_cache[id] = zero_type (ret) ? ZERO_TYPE : ret;    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,