Roxen.git / server / modules / scripting / piketag.pike

version» Context lines:

Roxen.git/server/modules/scripting/piketag.pike:1:   // This is a roxen module. Copyright © 1996 - 2000, Roxen IS.   //   // Adds support for inline pike in documents.   //   // Example:   // <pike>   // return "Hello world!\n";   // </pike>    - constant cvs_version = "$Id: piketag.pike,v 2.8 2000/08/09 02:33:09 per Exp $"; + constant cvs_version = "$Id: piketag.pike,v 2.9 2000/08/09 03:05:15 per Exp $";   constant thread_safe=1;      inherit "module";   #include <module.h>      constant module_type = MODULE_PARSER;   constant module_name = "Pike tag";   constant module_doc =   #"This module adds a new tag, &lt;pike&gt;&lt;/pike&gt;. It makes it   possible to insert some pike code directly in the document. <br>
Roxen.git/server/modules/scripting/piketag.pike:107:   }      string functions(string page, int line)   {    add_constant( "__ps_magic_helpers", Helpers );    return "inherit __ps_magic_helpers;\n" +    "#"+line+" \""+replace(page,"\"","\\\"")+"\"\n";   }      // Preamble - string pre(string what, object id) + string pre(array fl, object id)   { -  if(search(what, " parse(") != -1) +  foreach( fl, object token ) +  if( token == "parse" )    return functions(id->not_query, id->misc->line);    return functions(id->not_query, id->misc->line) +    "string|int parse(RequestID id) { ";   }      // Will be added at the end... - string post(string what) + string post(array fl)   { -  if(search(what, " parse(") != -1) +  foreach( fl, object token ) +  if( token == "parse" )    return "";    return "}";   }      private static mapping(string:program) program_cache = ([]);      string simple_pi_tag_pike( string tag, mapping m, string s,RequestID id )   {    return simpletag_pike( tag, ([]), s, id );   }
Roxen.git/server/modules/scripting/piketag.pike:141:   // program.   string simpletag_pike(string tag, mapping m, string s,RequestID request_id )   {    program p;    object o;    string res;    mixed err;       request_id->misc->cacheable=0;    +  array flat=Parser.C.hide_whitespaces(Parser.C.tokenize(Parser.C.split(s))); +     object e = ErrorContainer();    master()->set_inhibit_compile_errors(e);    if(err=catch    { -  s = pre(s,request_id)+s+post(s); +  for( int i = 0; i<sizeof( flat ); i++ ) +  if( flat[i] == "." && flat[++i] != "." ) +  flat[i-1]->text = "->"; +  +  s = pre(flat,request_id)+Parser.C.simple_reconstitute( flat )+post(flat);    p = program_cache[s];       if (!p)    {    // Not in the program cache.    object key = Roxen.add_scope_constants(); -  +     p = compile_string(s, "Pike-tag("+request_id->not_query+":"+    request_id->misc->line+")");    destruct( key );       if (sizeof(program_cache) > query("program_cache_limit"))    {    array a = indices(program_cache);    int i;       // Zap somewhere between 25 & 50% of the cache.