Branch: Tag:

2007-01-12

2007-01-12 20:13:06 by Martin Stjernholm <mast@lysator.liu.se>

Don't convert encodable RXML.Value and RXML.Scope objects to plain
values in scopes when p-code is encoded.

Rev: server/etc/modules/RXML.pmod/module.pmod:1.359

2:   //   // Created 1999-07-30 by Martin Stjernholm.   // - // $Id: module.pmod,v 1.358 2007/01/12 19:49:03 mast Exp $ + // $Id: module.pmod,v 1.359 2007/01/12 20:13:06 mast Exp $      // Kludge: Must use "RXML.refs" somewhere for the whole module to be   // loaded correctly.
1491:    string _sprintf (void|int flag) {return flag == 'O' && "RXML.Scope()";}   }    - mapping(string:mixed) scope_to_mapping (SCOPE_TYPE scope) + mapping(string:mixed) scope_to_mapping (SCOPE_TYPE scope, +  void|Context ctx, +  void|string scope_name)   //! Converts an RXML scope (in the form of a mapping or an object) to   //! a mapping. If @[scope] is a mapping, a shallow copy is returned.   //! If @[scope] is an object, every variable in it is queried to   //! produce the mapping. An error is thrown if the scope can't be   //! listed. -  + //! + //! The optional @[ctx] and @[scope_name] are passed on to the + //! @[RXML.Scope] object functions.   {    if (mappingp (scope))    return scope + ([]);       mapping(string:mixed) res = ([]); -  foreach (scope->_indices(), string var) { -  mixed val = scope[var]; -  if (!zero_type (val)) res[var] = val; +  foreach (scope->_indices (ctx, scope_name), string var) { +  mixed val = scope->`[] (var, ctx, scope_name); +  if (!zero_type (val) && val != nil) res[var] = val;    }    return res;   }
1964:    if (!oldvars) fatal_error ("I before e except after c.\n");   #endif    foreach (objectp (vars) ? -  ([object(Scope)] vars)->_indices (this_object(), scope_name || "_") : +  ([object(Scope)] vars)->_indices (this_object(), +  scope_name || "_") :    indices(vars), string var)    set_var(var, vars[var], scope_name);    }
3781:    if (!csf) csf = CacheStaticFrame (this_object()->scope_name); \    ctx->misc->recorded_changes[-1][csf] = \    objectp (vars) && vars->clone ? vars->clone() : \ -  scope_to_mapping (vars); \ +  scope_to_mapping (vars, ctx, this->scope_name); \    } \    } \    } while (0)
7313:    void eval_rxml_consts (Context ctx)    // This is used to evaluate constant RXML.Value objects before the    // p-code is saved so that we don't try to encode the objects -  // themselves. +  // themselves. We also convert RXML.Scope objects to mappings, but +  // we don't touch any objects that can be encoded as-is (i.e. have +  // is_RXML_encodable set).    {    foreach (indices (settings), mixed encoded_var)    if (stringp (encoded_var)) {
7322:    if (arrayp (var) && stringp (var[0]))    if (sizeof (var) == 1) {    if (SCOPE_TYPE vars = settings[encoded_var]) +  if (!objectp (vars) || !vars->is_RXML_encodable)    foreach (indices (vars), string name) {    mixed val = vars[name]; -  if (objectp (val) && val->rxml_const_eval) { +  if (objectp (val) && val->rxml_const_eval && +  !val->is_RXML_encodable) {   #ifdef DEBUG    if (TAG_DEBUG_TEST (ctx->frame))    TAG_DEBUG (ctx->frame, -  " Evaluating constant rxml value in scope %s: " -  "%s: %s\n", replace (var[0], ".", ".."), -  replace (name, ".", ".."), format_short (val)); +  " Evaluating constant rxml value " +  "in scope %s: %s: %s\n", +  replace (var[0], ".", ".."), +  replace (name, ".", ".."), +  format_short (val));   #endif    vars[name] = val->rxml_const_eval (ctx, name, var[0]);    }
7339:       else {    mixed val = settings[encoded_var]; -  if (objectp (val) && val->rxml_const_eval) { +  if (objectp (val) && val->rxml_const_eval && +  !val->is_RXML_encodable) {   #ifdef DEBUG    if (TAG_DEBUG_TEST (ctx->frame))    TAG_DEBUG (ctx->frame,
7348:    format_short (val));   #endif    settings[encoded_var] = -  val->rxml_const_eval (ctx, var[-1], var[..sizeof (var) - 2] * "."); +  val->rxml_const_eval (ctx, var[-1], +  var[..sizeof (var) - 2] * ".");    }    }    }