Branch: Tag:

2001-05-31

2001-05-31 00:14:22 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Backported handler fixes from Pike 7.3.

Rev: lib/master.pike.in:1.147
Rev: src/program.c:1.294

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.    *
653:      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;
677:    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;
729:    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;    }   
908:   // /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]))
919:    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;   }   
943:    tmp[-1]=what;    path=combine_path_with_cwd( tmp*"/");    } +  if (handler) { +  return dirnode(path, handler); +  }    return fc[path]=dirnode(path);   }   
1080:    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) {
1119:    }       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;   
1129:    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;