Branch: Tag:

2008-09-13

2008-09-13 15:31:58 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Cleaned up the get_compat_master() code to be more easy to understand.
get_compat_master() in old masters is now capable of returning more recent masters.

Rev: lib/master.pike.in:1.454

6:   // Pike is distributed under GPL, LGPL and MPL. See the file COPYING   // for more information.   // - // $Id: master.pike.in,v 1.453 2008/08/31 20:19:14 grubba Exp $ + // $Id: master.pike.in,v 1.454 2008/09/13 15:31:58 grubba Exp $      #pike __REAL_VERSION__   //#pragma strict_types
144:      //! Pike 0.6 master compatibility interface.   //! - //! Most of the interface is implemented via mixin. + //! Most of the interface is implemented via mixin, + //! or overloading by more recent masters.   //! -  + //! This interface is used for compatibility with + //! all pikes until Pike 0.6. + //!   //! @deprecated predef::MasterObject   //!   //! @seealso
342:    string describe_backtrace(array(mixed) trace);    class Codec {};    -  object get_compat_master(int major, int minor); +  object get_compat_master(int major, int minor) +  { +  // 0.0 - 0.6 +  if (!major && (minor < 7)) +  return this_program::this; +  return get_compat_master(major, minor);    } -  + }      //! Pike 7.0 master compatibility interface.   //! - //! Most of the interface is implemented via mixin. + //! Most of the interface is implemented via mixin, + //! or overloading by more recent masters.   //! -  + //! This interface is used for compatibility with + //! Pike 0.7 through 7.0. + //!   //! @deprecated predef::MasterObject   //!   //! @seealso
563:       object get_compat_master(int major, int minor)    { -  return Pike_0_6_master::this; +  if (!major && (minor < 7)) +  return Pike_0_6_master::get_compat_master(major, minor); +  // 0.7 - 7.0 +  if ((major < 7) || ((major == 7) && !minor)) +  return this_program::this; +  return get_compat_master(major, minor);    }   }      //! Pike 7.2 master compatibility interface.   //! - //! Most of the interface is implemented via mixin. + //! Most of the interface is implemented via mixin, + //! or overloading by more recent masters.   //! -  + //! This interface is used for compatibility with + //! Pike 7.1 and 7.2. + //!   //! @deprecated predef::MasterObject   //!   //! @seealso
611:    extern object currentversion;    extern mapping(object:object) compat_handler_cache;    object get_compilation_handler(int major, int minor); -  string _sprintf(); -  local string _sprintf(int|void t) -  { -  return UNDEFINED; -  } +  string _sprintf(int|void t);    object get_compat_master(int major, int minor)    { -  if ((major > 0) || (minor > 6)) return Pike_7_0_master::this; +  if ((major < 7) || ((major == 7) && (minor < 1)))    return Pike_7_0_master::get_compat_master(major, minor); -  +  // 7.1 & 7.2 +  if ((major == 7) && (minor < 3)) +  return this_program::this; +  return get_compat_master(major, minor);    }   }      //! Pike 7.4 master compatibility interface.   //! - //! Most of the interface is implemented via mixin. + //! Most of the interface is implemented via mixin, + //! or overloading by more recent masters.   //! -  + //! This interface is used for compatibility with + //! Pike 7.3 and 7.4. + //!   //! @deprecated predef::MasterObject   //!   //! @seealso
679:    }    object get_compat_master(int major, int minor)    { -  if ((major == 7) && (minor > 0)) return Pike_7_2_master::this; +  if ((major < 7) || ((major == 7) && (minor < 3)))    return Pike_7_2_master::get_compat_master(major, minor); -  +  // 7.3 & 7.4 +  if ((major == 7) && (minor < 5)) +  return this_program::this; +  return get_compat_master(major, minor);    }   }      //! Pike 7.6 master compatibility interface.   //! - //! Most of the interface is implemented via mixin. + //! Most of the interface is implemented via mixin, + //! or overloading by more recent masters.   //! -  + //! This interface is used for compatibility with + //! Pike 7.5 and 7.6. + //!   //! @deprecated predef::MasterObject   //!   //! @seealso
706:    array get_backtrace (object|array err);    object get_compat_master(int major, int minor)    { -  if ((major == 7) && (minor > 2)) return Pike_7_4_master::this; +  if ((major < 7) || ((major == 7) && (minor < 5)))    return Pike_7_4_master::get_compat_master(major, minor); -  +  // 7.5 & 7.6 +  if ((major == 7) && (minor < 7)) +  return this_program::this; +  return get_compat_master(major, minor);    }   }   
5583:   //!   //! @seealso   //! @[get_compilation_handler()], @[master()] - local object get_compat_master(int major, int minor) + object get_compat_master(int major, int minor)   { -  if ((major > 7) || ((major == 7) && (minor > 6))) return this; -  if ((major == 7) && (minor > 4)) return Pike_7_6_master::this; +  if ((major < 7) || ((major == 7) && (minor < 7)))    return Pike_7_6_master::get_compat_master(major, minor); -  +  // 7.7 and later. +  return this;   }