pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:423:      //! Namespaces for compat masters.   //!   //! This inherit is used to provide compatibility namespaces   //! for @[get_compat_master()].   //!   //! @seealso   //! @[get_compat_master()]   protected inherit Pike_8_0_master;    - //! @appears error + //! @namespace predef:: +    //! Throws an error. A more readable version of the code   //! @expr{throw( ({ sprintf(f, @@args), backtrace() }) )@}.   void error(sprintf_format f, sprintf_args ... args) {    if (sizeof(args)) f = sprintf(f, @args);    throw( ({ f, backtrace()[..<1] }) );   }      // FIXME: Should the pikeroot-things be private?   #ifdef PIKE_FAKEROOT   object o;
pike.git/lib/master.pike.in:493:    return s;   }      #ifdef fakeroot   #undef fakeroot   #endif   #define fakeroot relocate_module   #endif // PIKE_MODULE_RELOC       - //! @appears is_absolute_path +    //! Check if a path @[p] is fully qualified (ie not relative).   //!   //! @returns   //! Returns 1 if the path is absolute, 0 otherwise.   int is_absolute_path(string p)   {   #ifdef __amigaos__   #define IS_ABSOLUTE_PATH(X) (search((X),":")>0)    return IS_ABSOLUTE_PATH(p);   #else
pike.git/lib/master.pike.in:522:    return has_prefix(p,"/");   #endif   }      #if defined(__NT__) || defined(__OS2__)   #define EXPLODE_PATH(X) (replace((X),"\\","/")/"/")   #else   #define EXPLODE_PATH(X) ((X)/"/")   #endif    - //! @appears explode_path +    //! Split a path @[p] into its components.   //!   //! This function divides a path into its components. This might seem like   //! it could be done by dividing the string on <tt>"/"</tt>, but that will   //! not work on some operating systems. To turn the components back into   //! a path again, use @[combine_path()].   //!   array(string) explode_path(string p)   {   #ifdef __amigaos__
pike.git/lib/master.pike.in:546:    array(string) r = p/"/";    return replace(r[..<1], "", "/")+r[<0..];   #else    array(string) r = EXPLODE_PATH(p);    if(r[0] == "" && sizeof(p))    r[0] = "/";    return r;   #endif   }    - //! @appears dirname +    //! Returns all but the last segment of a path. Some example inputs and   //! outputs:   //!   //! @xml{<matrix>   //! <r><c><b>Expression</b></c><c><b>Value</b></c></r>   //! <r><c>dirname("/a/b")</c><c>"/a"</c></r>   //! <r><c>dirname("/a/")</c><c>"/a"</c></r>   //! <r><c>dirname("/a")</c><c>"/"</c></r>   //! <r><c>dirname("/")</c><c>"/"</c></r>   //! <r><c>dirname("")</c><c>""</c></r>
pike.git/lib/master.pike.in:577:    tmp[-1]=tmp2[..<1]*"/";    if(sizeof(tmp2) >= 2 && tmp2[-2]=="") tmp[-1]+="/";    return tmp*":";   #else    array(string) tmp=EXPLODE_PATH(x);    if(x[0]=='/' && sizeof(tmp)<3) return "/";    return tmp[..<1]*"/";   #endif   }    - //! @appears basename +    //! Returns the last segment of a path.   //!   //! @seealso   //! @[dirname()], @[explode_path()]   string basename(string x)   {   #ifdef __amigaos__    return ((x/":")[-1]/"/")[-1];   #define BASENAME(X) ((((X)/":")[-1]/"/")[-1])   #else
pike.git/lib/master.pike.in:638:      mapping(string:int) load_time=([]);   #else      #define AUTORELOAD_CHECK_FILE(X)   #define AUTORELOAD_BEGIN()   #define AUTORELOAD_FINISH(VAR,CACHE,FILE)      #endif // PIKE_AUTORELOAD    - //! @appears compile_string +    //! Compile the Pike code in the string @[source] into a program.   //! If @[filename] is not specified, it will default to @expr{"-"@}.   //!   //! Functionally equal to @expr{@[compile](@[cpp](@[source], @[filename]))@}.   //!   //! @seealso   //! @[compile()], @[cpp()], @[compile_file()]   //!   program compile_string(string source, void|string filename,    object|void handler,
pike.git/lib/master.pike.in:679:    o);    if (source_cache)    source_cache[ret] = source;   #ifdef RECUR_COMPILE_DEBUG    DEC_MSG_DEPTH();    werror ("%*s<<< compile_string %O\n", GET_MSG_DEPTH, "", filename);   #endif    return ret;   }    + //! @endnamespace +    //!   string master_read_file(string file)   {    string x = find_handler_for_path(file);    if(x)    {    object h = fs_map[x];    file = file[sizeof(x)+1..];       if(h = h->open(fakeroot(file),"r") )
pike.git/lib/master.pike.in:866:      #ifdef __NT__   protected void set_lc_env (mapping(string:string) env)   {    environment = ([]);    foreach (env; string var; string val)    environment[lower_case (var)] = val;   }   #endif    + //! @namespace predef:: +    //! @decl mapping(string:string) getenv (void|int force_update)   //!   //! Queries the environment variables.   //!   //! @param force_update   //! A cached copy of the real environment is kept to make this   //! function quicker. If the optional flag @[force_update] is nonzero   //! then the real environment is queried and the cache is updated from   //! it. That can be necessary if the environment changes through other   //! means than @[putenv], typically from a C-level library.
pike.git/lib/master.pike.in:990:    if (environment) {   #ifdef __NT__    varname = lower_case (varname);   #endif    if (value) environment[varname] = value;    else m_delete (environment, varname);    }   }       - //! @appears compile_file +    //! Compile the Pike code contained in the file @[filename] into a program.   //!   //! This function will compile the file @[filename] to a Pike program that can   //! later be instantiated. It is the same as doing   //! @expr{@[compile_string](@[Stdio.read_file](@[filename]), @[filename])@}.   //!   //! @seealso   //! @[compile()], @[compile_string()], @[cpp()]   //!   program compile_file(string filename,
pike.git/lib/master.pike.in:1024:    }    return compile(code,    handler,    compat_major,    compat_minor,    p,    o);   }       - //! @appears normalize_path +    //! Replaces "\" with "/" if runing on MS Windows. It is   //! adviced to use @[System.normalize_path] instead.   string normalize_path( string path )   {   #ifndef __NT__    return path;   #else    return replace(path,"\\","/");   #endif   }    -  + //! @endnamespace +    //! Mapping containing the cache of currently compiled files.   //!   //! This mapping currently has the following structure:   //! @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
pike.git/lib/master.pike.in:1754:    "false",    "getenv",    "putenv",      #ifdef GETCWD_CACHE    "cd",    "getcwd",   #endif   });    - enum bool { false=0, true=1 }; -  +    //! Prefix for Pike-related C header files.   string include_prefix;      //! Prefix for autodoc files.   string doc_prefix;      //! Flags suitable for use when compiling Pike C modules   string cflags;      //! Flags suitable for use when linking Pike C modules   string ldflags; // Not yet used    -  + //! @namespace predef:: + //! + //! This is the default namespace and contains lots of global symbols.    -  + //! Boolean datatype. + enum bool { false=0, true=1 }; +    //! @decl int write(string fmt, mixed ... args) - //! @appears write +    //! Writes a string on stdout. Works just like @[Stdio.File.write]   //! on @[Stdio.stdout].      //! @decl int werror(string fmt, mixed ... args) - //! @appears werror +    //! Writes a string on stderr. Works just like @[Stdio.File.write]   //! on @[Stdio.stderr].    -  + //! @decl array random(mapping m) + //! @decl float random(float max) + //! @decl int random(int max) + //! @decl mixed random(object o) + //! @decl mixed random(array|multiset x) + //! + //! Get a random value generated by the default @[RandomSystem]. + //! + //! @seealso + //! @[RandomSystem()->random()], @[random_string()] +  + //! @decl string random_string(int len) + //! + //! Get a string of random characters @expr{0..255@} with the length @[len] + //! from the default @[RandomSystem]. + //! + //! @seealso + //! @[RandomSystem()->random_string()], @[random()] +    /* Note that create is called before add_precompiled_program    */   protected void create()   {    foreach(master_efuns, string e)    if (has_index(this, e))    add_constant(e, this[e]);    else    error("Function %O is missing from master.pike.\n", e);   
pike.git/lib/master.pike.in:1860:    // for use with embedded interpreters    // add path for architecture-dependant files    add_include_path(__embedded_resource_directory + "/lib/include");    add_module_path(__embedded_resource_directory + "/lib/modules");    add_module_path(__embedded_resource_directory + "/" + replace(uname()->machine, " ", "_") + "/modules");      #endif    system_module_path=pike_module_path;   }    + //! @endnamespace      //! 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)
pike.git/lib/master.pike.in:3167:    }       protected string _sprintf(int t)    {    return t=='O' && sprintf("CompatResolver(%O)",ver);    }   }      inherit CompatResolver;    + //! @namespace predef:: +  + //! @class __dirnode +  + //! @decl inherit MasterObject.dirnode +  + //! @endclass +  + //! @class __joinnode +  + //! @decl inherit MasterObject.joinnode +  + //! @endclass +  + //! @decl void add_include_path(string tmp) + //! Add a directory to search for include files. + //! + //! This is the same as the command line option @tt{-I@}. + //! + //! @note + //! Note that the added directory will only be searched when using + //! < > to quote the included file. + //! + //! @seealso + //! @[remove_include_path()] + //! +  + //! @decl void remove_include_path(string tmp) + //! Remove a directory to search for include files. + //! + //! This function performs the reverse operation of @[add_include_path()]. + //! + //! @seealso + //! @[add_include_path()] + //! +  + //! @decl void add_module_path(string path, string|void subpath) + //! Add a directory to search for modules. + //! + //! This is the same as the command line option @tt{-M@}. + //! + //! @seealso + //! @[remove_module_path()] + //! + //! @param path + //! a string containing a path to search for Pike modules. May be a + //! directory, or a path to a ZIP archive. If a ZIP archive path is + //! provided, modules will be loaded from a directory, "modules" within + //! the ZIP archive (see the subpath argument). + //! + //! @param subpath + //! if path is a ZIP archive, this argument will determine the path within + //! the archive to be searched. + //! +  + //! @decl void remove_module_path(string tmp) + //! Remove a directory to search for modules. + //! + //! This function performs the reverse operation of @[add_module_path()]. + //! + //! @seealso + //! @[add_module_path()] + //! +  + //! @decl void add_program_path(string tmp) + //! Add a directory to search for programs. + //! + //! This is the same as the command line option @tt{-P@}. + //! + //! @seealso + //! @[remove_program_path()] + //! +  + //! @decl void remove_program_path(string tmp) + //! Remove a directory to search for programs. + //! + //! This function performs the reverse operation of @[add_program_path()]. + //! + //! @seealso + //! @[add_program_path()] + //! +  + //! @endnamespace +    //! 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;      // Gets set to 1 if we're in async-mode (script->main() returned <0)   private int(0..1) _async=0;      //! Returns 1 if we┬┤re in async-mode, e.g. if the main method has   //! returned a negative number.
pike.git/lib/master.pike.in:4402:    return s+"->"+name;    }    return name;   }      /* It is possible that this should be a real efun,    * it is currently used by handle_error to convert a backtrace to a    * readable message.    */    - //! @appears describe_backtrace + //! @namespace predef:: +    //! Return a readable message that describes where the backtrace   //! @[trace] was made (by @[backtrace]).   //!   //! It may also be an error object or array (typically caught by a   //! @[catch]), in which case the error message also is included in the   //! description.   //!   //! Pass @[linewidth] -1 to disable wrapping of the output.   //!   //! @seealso
pike.git/lib/master.pike.in:4643:    -loop_start, loops)});    frames += tail;    }       ret += frames * "";    }       return ret;   }    - //! @appears describe_error - //! +    //! Return the error message from an error object or array (typically   //! caught by a @[catch]). The type of the error is checked, hence   //! @[err] is declared as @expr{mixed@} and not @expr{object|array@}.   //!   //! If an error message couldn't be obtained, a fallback message   //! describing the failure is returned. No errors due to incorrectness   //! in @[err] are thrown.   //!   //! @seealso   //! @[describe_backtrace()], @[get_backtrace]
pike.git/lib/master.pike.in:4694:    }       else if (arrayp(err) && sizeof([array]err)==2 &&    (!(msg = ([array]err)[0]) || stringp (msg)))    return [string] msg || "<No error message>\n";       else    return sprintf ("<Invalid error container: %O>\n", err);   }    - //! @appears get_backtrace - //! +    //! Return the backtrace array from an error object or array   //! (typically caught by a @[catch]), or zero if there is none. Errors   //! are thrown on if there are problems retrieving the backtrace.   //!   //! @seealso   //! @[describe_backtrace()], @[describe_error()]   //!   array get_backtrace (object|array err)   {    array bt;
pike.git/lib/master.pike.in:4733:    else if (arrayp(err) && sizeof([array]err)==2 &&    (!(bt = ([array]err)[1]) || arrayp (bt)))    {}       else if (err)    error ("Invalid error container: %O\n", err);       return bt;   }    + //! @endnamespace +    void thread_quanta_exceeded(object thread, int ns)   {    werror("Thread quanta exceeded for %O (%d ns):\n"    "%s\n",    thread, ns,    describe_backtrace(thread->backtrace()));   }         #ifdef ENCODE_DEBUG