Branch: Tag:

2000-02-13

2000-02-13 10:32:22 by Martin Stjernholm <mast@lysator.liu.se>

Rewrote <cond> to new style.

Rev: server/base_server/rxml.pike:1.122

1:   /* -  * $Id: rxml.pike,v 1.121 2000/02/12 21:31:57 mast Exp $ +  * $Id: rxml.pike,v 1.122 2000/02/13 10:32:22 mast Exp $    *    * The Roxen RXML Parser.    *
171: Inside #if undefined(manual)
   c->add_scope("var", ([]) );    }    -  // These are only used in new style tags. +  // These are not used when the result type for the parser is t_xml +  // or t_html.    constant low_entities = ([    "quot": "\"",    "amp": "&",
550: Inside #if undefined(manual)
   lambda(string tag){ return GenericTag(tag, @defs[tag]); }));       if (search (rxml_tag_set->imported, tag_set) < 0) { -  rxml_tag_set->modules = rxml_tag_set->modules + ({mod}); -  rxml_tag_set->imported = rxml_tag_set->imported + ({tag_set}); +  rxml_tag_set->modules += ({mod}); +  rxml_tag_set->imported += ({tag_set});    remove_call_out (rxml_tag_set->sort_on_priority);    call_out (rxml_tag_set->sort_on_priority, 0);    }
1134:      #define LAST_IF_TRUE id->misc->defines[" _ok"]    - class TagIf { -  inherit RXML.Tag; -  constant name = "if"; -  constant flags = RXML.FLAG_CONTAINER | RXML.FLAG_SOCKET_TAG; -  -  class Frame { + class FrameIf {    inherit RXML.Frame;    int do_iterate = -1;   
1188:    return 0;    }    } +  + class TagIf { +  inherit RXML.Tag; +  constant name = "if"; +  constant flags = RXML.FLAG_CONTAINER | RXML.FLAG_SOCKET_TAG; +  constant Frame = FrameIf;   }      string tag_else( string t, mapping m, string c, RequestID id )
1220:    return "";   }    - private void internal_tag_case( string t, mapping m, string c, int l, RequestID id, -  mapping res ) + class TagCond   { -  if(res->res) return; -  LAST_IF_TRUE = 0; -  // tag_if( t, m, c, id ); -  if(LAST_IF_TRUE) res->res = c+"<true>"; -  return; +  inherit RXML.Tag; +  constant name = "cond"; +  constant flags = RXML.FLAG_CONTAINER; +  RXML.Type content_type = RXML.t_none (RXML.PHtml); +  array(RXML.Type) result_types = ({RXML.t_any}); +  +  class TagCase +  { +  inherit RXML.Tag; +  constant name = "case"; +  constant flags = RXML.FLAG_CONTAINER; +  array(RXML.Type) result_types = ({RXML.t_none}); +  +  class Frame +  { +  inherit FrameIf; +  +  array do_enter (RequestID id) +  { +  if (up->result != RXML.Void) return 0; +  content_type = up->result_type (RXML.PHtml); +  return ::do_enter (id);    }    - string tag_cond( string t, mapping m, string c, RequestID id ) +  array do_return (RequestID id)    { -  mapping result = ([]); -  parse_html_lines(c,([]),(["case":internal_tag_case, -  "default":lambda(mixed ... a){ -  result->def = a[2]+"<false>"; }]),id,result); -  return result->res||result->def; +  ::do_return (id); +  up->result = result; +  result = RXML.Void; +  return 0;    }    -  +  // Must override this since it's used by FrameIf. +  mapping(string:RXML.Tag) get_plugins() +  {return RXML.get_context()->tag_set->get_plugins ("if");} +  } +  } +  +  class TagDefault +  { +  inherit RXML.Tag; +  constant name = "default"; +  constant flags = RXML.FLAG_CONTAINER; +  array(RXML.Type) result_types = ({RXML.t_none}); +  +  class Frame +  { +  inherit RXML.Frame; +  int do_iterate = 1; +  +  array do_enter() +  { +  if (up->result != RXML.Void) { +  do_iterate = -1; +  return 0; +  } +  content_type = up->result_type (RXML.PNone); +  return 0; +  } +  +  array do_return() +  { +  up->default_data = content; +  return 0; +  } +  } +  } +  +  RXML.TagSet cond_tags = +  RXML.TagSet ("TagCond.cond_tags", ({TagCase(), TagDefault()})); +  +  class Frame +  { +  inherit RXML.Frame; +  RXML.TagSet local_tags = cond_tags; +  string default_data; +  +  array do_return (RequestID id) +  { +  if (result == RXML.Void && default_data) { +  LAST_IF_TRUE = 0; +  return ({RXML.parse_frame (result_type (RXML.PHtml), default_data)}); +  } +  return 0; +  } +  } + } +    class TagEmit {    inherit RXML.Tag;    constant name = "emit";
1302:    "noparse":tag_noparse,    "nooutput":tag_nooutput,    "case":tag_case, -  "cond":tag_cond, +     "strlen":tag_strlen,    "define":tag_define,    "trace":tag_trace,