Branch: Tag:

2008-06-24

2008-06-24 12:44:46 by Martin Stjernholm <mast@lysator.liu.se>

Use wrapper objects from the compat all_constants mappings, so that
changes get reflected in the real constants mapping.

Rev: lib/7.4/modules/__default.pmod:1.18
Rev: lib/7.6/modules/__default.pmod:1.9
Rev: lib/master.pike.in:1.444

6:   // Pike is distributed under GPL, LGPL and MPL. See the file COPYING   // for more information.   // - // $Id: master.pike.in,v 1.443 2008/06/10 12:43:17 mast Exp $ + // $Id: master.pike.in,v 1.444 2008/06/24 12:44:46 mast Exp $      #pike __REAL_VERSION__   //#pragma strict_types
681:   //! @[get_compat_master()]   static inherit Pike_7_6_master;    + class CompatAllConstants (mapping(string:mixed) compat_overrides) + // Wrapper for the mapping returned by all_constants in compat mode. + { +  static mixed `[] (string sym) +  { +  mixed val = compat_overrides[sym]; +  if (zero_type (val)) val = predef::all_constants()[sym]; +  return val; +  } +  static mixed `-> (string sym) +  {return `[] (sym);} +  +  static mixed `[]= (string sym, mixed val) +  {return predef::all_constants()[sym]= val;} +  static mixed `->= (string sym, mixed val) +  {return `[]= (sym, val);} +  +  static array(string) _indices() +  {return indices (predef::all_constants() | compat_overrides);} +  static array(mixed) _values() +  {return values (predef::all_constants() | compat_overrides);} +  +  static mapping `+ (mapping other) +  {return (predef::all_constants() | compat_overrides) + other;} +  static mapping ``+ (mapping other) +  {return other + (predef::all_constants() | compat_overrides);} +  static mapping `| (mapping other) +  {return (predef::all_constants() | compat_overrides) | other;} +  static mapping ``| (mapping other) +  {return other | (predef::all_constants() | compat_overrides);} + } +    //! @appears error   //! Throws an error. A more readable version of the code   //! @expr{throw( ({ sprintf(f, @@args), backtrace() }) )@}.