pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   /* -*- Pike -*-    * -  * $Id: master.pike.in,v 1.160 2001/07/27 14:42:19 nilsson Exp $ +  * $Id: master.pike.in,v 1.161 2001/07/28 14:11:14 nilsson Exp $    *    * Master-file for Pike.    *    * Based on master.pike 1.67.    */      // Some configurable parameters useful for debugging      #pike __REAL_VERSION__   #define PIKE_AUTORELOAD      // Used by describe_backtrace() et al.   #if !defined(BT_MAX_STRING_LEN) || (BT_MAX_STRING_LEN <= 0)   #undef BT_MAX_STRING_LEN   #define BT_MAX_STRING_LEN 200   #endif /* !defined(BT_MAX_STRING_LEN) || (BT_MAX_STRING_LEN <= 0) */   constant bt_max_string_len = BT_MAX_STRING_LEN;    -  + //! @decl constant bt_max_string_len = int +    // Enables the out of date warning in low_find_prog().   #ifndef OUT_OF_DATE_WARNING   #define OUT_OF_DATE_WARNING 1   #endif /* OUT_OF_DATE_WARNING */   constant out_of_date_warning = OUT_OF_DATE_WARNING;    -  + //! @decl constant out_of_date_warning = int(0..1) +    #ifndef PIKE_WARNINGS   #define PIKE_WARNINGS 0   #endif /* PIKE_WARNINGS */      /*    * Functions begin here.    */      #ifdef PIKE_FAKEROOT   object o;
pike.git/lib/master.pike.in:109:   }   #define DIRNAME dirname   #define BASENAME(X) (EXPLODE_PATH(X)[-1])      #define GETCWD_CACHE   #define FILE_STAT_CACHE      #define UNDEFINED (([])[0])   #define error(X) throw( ({ (X), backtrace()/*[0..sizeof(backtrace())-2]*/ }) )    + //!   int want_warnings = PIKE_WARNINGS;      #ifdef PIKE_AUTORELOAD      int autoreload_on;   int newest;      #define AUTORELOAD_CHECK_FILE(X) \    if(autoreload_on) if(mixed fnord=master_file_stat(X)) if(fnord[3]>newest) newest=fnord[3];   
pike.git/lib/master.pike.in:143:      mapping(string:int) load_time=([]);   #else      #define AUTORELOAD_CHECK_FILE(X)   #define AUTORELOAD_BEGIN()   #define AUTORELOAD_FINISH(VAR,CACHE,FILE)      #endif    + //!   int compat_major=-1; -  +  + //!   int compat_minor=-1;      //! @appears compile_string   //! Compile the Pike code in the string @[data] into a program.   //! If @[filename] is not specified, it will default to @tt{"-"@}.   //!   //! Functionally equal to @code{@[compile](@[cpp](@[source], @[filename]))@}.   //!   //! @seealso   //! @[compile()], @[cpp()], @[compile_file()]
pike.git/lib/master.pike.in:165:   program compile_string(string source, void|string filename,    object|void handler)   {    return compile(cpp(source, filename||"-", 1, handler,    compat_major, compat_minor),    handler,    compat_major,    compat_minor);   }    -  + //!   string master_read_file(string file)   {    object o=_static_modules.files()->Fd();    if(o->open(fakeroot(file),"r"))    return o->read();    return 0;   }      #ifdef GETCWD_CACHE   string current_path;
pike.git/lib/master.pike.in:543:       foreach(pike_program_path, string path)    if(program ret=findprog(combine_path(path,pname),ext,handler,mkobj))    return ret;       return 0;    }   }       - /* This function is called when the driver wants to cast a string -  * to a program, this might be because of an explicit cast, an inherit -  * or a implict cast. In the future it might receive more arguments, -  * to aid the master finding the right program. -  */ + //! This function is called when the driver wants to cast a string + //! to a program, this might be because of an explicit cast, an inherit + //! or a implict cast. In the future it might receive more arguments, + //! to aid the master finding the right program.   program cast_to_program(string pname,    string current_file,    object|void handler)   {    return low_cast_to_program(pname, current_file, handler);   }       - /* This function is called when an error occurs that is not caught -  * with catch(). -  */ + //! This function is called when an error occurs that is not caught + //! with catch().   void handle_error(array(mixed)|object trace)   {    if(mixed x=catch {    werror(describe_backtrace(trace));    }) {    // One reason for this might be too little stack space, which    // easily can occur for "out of stack" errors. It should help to    // tune up the STACK_MARGIN values in interpret.c then.    werror("Error in handle_error in master object:\n");    if(catch {
pike.git/lib/master.pike.in:693:    add_module_path("¤share_prefix¤/modules");   #endif      #if "¤lib_prefix¤"[0]!='¤'    // add path for architecture-dependant files    add_include_path("¤lib_prefix¤/include");    add_module_path("¤lib_prefix¤/modules");   #endif   }    - /* -  * This function is called whenever a inherit is called for. -  * It is supposed to return the program to inherit. -  * The first argument is the argument given to inherit, and the second -  * is the file name of the program currently compiling. Note that the -  * file name can be changed with #line, or set by compile_string, so -  * it can not be 100% trusted to be a filename. -  * previous_object(), can be virtually anything in this function, as it -  * is called from the compiler. -  */ +  + //! This function is called whenever a inherit is called for. + //! It is supposed to return the program to inherit. + //! The first argument is the argument given to inherit, and the second + //! is the file name of the program currently compiling. Note that the + //! file name can be changed with #line, or set by compile_string, so + //! it can not be 100% trusted to be a filename. + //! 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|void current_handler)   {    program p;    object o;       p = low_cast_to_program(oname, current_file, current_handler, 1);    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. -  */ + //! 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(string dirname, object|void handler)
pike.git/lib/master.pike.in:1214:    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, 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 -  */ +  //! 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);
pike.git/lib/master.pike.in:1262:          string _sprintf()    {    return sprintf("CompatResolver(%s)",ver);    }   }      inherit CompatResolver;    - // These are useful if you want to start other Pike processes - // with the same options as this one was started with. + //! These are useful if you want to start other Pike processes + //! with the same options as this one was started with.   string _pike_file_name;   string _master_file_name;      //flag. Gets set to 1 if we're in async-mode (script->main() returned <0)   private int _async=0;      int asyncp() {    return _async;   }    - // The backend_thread() function is useful to determine if you are - // the backend thread - important when doing async/sync protocols -  +    #if constant(thread_create)   // this must be done in __init if someone inherits the master   static object _backend_thread=this_thread(); -  +  + //! The backend_thread() function is useful to determine if you are + //! the backend thread - important when doing async/sync protocols. + //! This method is only available if thread_create is present.   object backend_thread()   {    return _backend_thread;   }   #endif    - /* This function is called when all the driver is done with all setup -  * of modules, efuns, tables etc. etc. and is ready to start executing -  * _real_ programs. It receives the arguments not meant for the driver -  * and an array containing the environment variables on the same form as -  * a C program receives them. -  */ + //! This function is called when all the driver is done with all setup + //! of modules, efuns, tables etc. etc. and is ready to start executing + //! _real_ programs. It receives the arguments not meant for the driver + //! and an array containing the environment variables on the same form as + //! a C program receives them.   void _main(array(string) orig_argv, array(string) env)   {    array(string) argv=copy_value(orig_argv);    int i,debug,trace;    object tmp;    string a,b;    array q;    string postparseaction=0;    mixed v;   
pike.git/lib/master.pike.in:1698:    return s;   }      function(string:string) set_trim_file_name_callback(function(string:string) s)   {    function(string:string) f=_trim_file_name_cb;    _trim_file_name_cb=s;    return f;   }    - /* -  * This function is called whenever a compiling error occurs. -  * Nothing strange about it. -  * Note that previous_object cannot be trusted in ths function, because -  * the compiler calls this function. -  */ +  + //! This function is called whenever a compiling error occurs. + //! Nothing strange about it. + //! Note that previous_object cannot be trusted in ths function, because + //! the compiler calls this function.   void compile_error(string file,int line,string err)   {    mixed val;    if(! (val = get_inhibit_compile_errors() ))    {    werror(sprintf("%s:%s:%s\n",trim_file_name(file),    line?(string)line:"-",err));    }    else if(objectp(val) ||    programp(val) ||    functionp(val))    {    if (objectp(val) && val->compile_error) {    val->compile_error(file, line, err);    } else {    val(file, line, err);    }    }   }    - /* -  * This function is called whenever a compiling warning occurs. -  * Nothing strange about it. -  * Note that previous_object cannot be trusted in ths function, because -  * the compiler calls this function. -  */ +  + //! This function is called whenever a compiling warning occurs. + //! Nothing strange about it. + //! Note that previous_object cannot be trusted in ths function, because + //! the compiler calls this function.   void compile_warning(string file,int line,string err)   {    mixed val;       if(!(val = get_inhibit_compile_errors() ))    {    if(want_warnings)    werror(sprintf("%s:%s: Warning: %s\n",trim_file_name(file),    line?(string)line:"-",err));    } else if (objectp(val) && val->compile_warning) {    val->compile_warning(file, line, err);    }   }    - /* -  * Called for every runtime warning. The first argument identifies -  * where the warning comes from, the second identifies the specific -  * message, and the rest depends on that. See code below for currently -  * implemented warnings. -  */ +  + //! Called for every runtime warning. The first argument identifies + //! where the warning comes from, the second identifies the specific + //! message, and the rest depends on that. See code below for currently + //! implemented warnings.   void runtime_warning (string where, string what, mixed... args)   {    if (want_warnings)    switch (where + "." + what) {    case "gc.bad_cycle":    // args[0] is an array containing the objects in the cycle    // which aren't destructed and have destroy() functions.    werror ("GC warning: Garbing cycle where destroy() will be called "    "in arbitrary order:\n%{ %s\n%}",    map (args[0], describe_object));    break;       default:    werror ("%s warning: %s %O\n", capitalize (where), what, args);    }   }         static mixed _charset_mod; - /* This function is called by cpp() when it wants to do -  * character code conversion. -  */ +  + //! This function is called by cpp() when it wants to do + //! character code conversion.   string decode_charset(string data, string charset)   {    // werror(sprintf("decode_charset(%O, %O)\n", data, charset));       if (!_charset_mod) {    mixed mod = resolv("Locale");       _charset_mod = mod && mod["Charset"];    if (!_charset_mod) {    compile_warning("-", 0, "No Locale.Charset module!");
pike.git/lib/master.pike.in:2027:    done++;    break;    }    }    }       return ret;    }   }    + //!   string describe_object(object o)   {    string s;    if(!o) return 0;    if (!catch (s = sprintf("%O",o)) && s != "object") return s;    if(( s=describe_program(object_program(o)) ))    return s+"()";    return 0;   }    -  + //!   string describe_program(program p)   {    string s;    if(!p) return 0;    if(s=search(programs,p))    {    if(sscanf(reverse(s),"%s.%s",string ext,string rest) && ext=="domp")    return EXPLODE_PATH(reverse(rest))[-1];    return trim_file_name(s);    }
pike.git/lib/master.pike.in:2069:    }    }          if(s=_static_modules.Builtin()->program_defined(p))    return EXPLODE_PATH(s)[-1];       return 0;   }    + //!   string describe_function (function f)   {    if (!f) return 0;       string name;       if(string s=search(programs,f))    {    if(sscanf(reverse(s),"%s.%s",string ext,string rest) && ext=="domp")    name = EXPLODE_PATH(reverse(rest))[-1];