pike.git / lib / modules / Val.pmod

version» Context lines:

pike.git/lib/modules/Val.pmod:11:   //! base classes defined here provide required functionality directly.   //!   //! @note   //! Since resolving using the dot operator in e.g. @[Val.null] is   //! done at compile time, replacement of these values often must take   //! place very early (typically in a loader before the bulk of the   //! pike code is compiled) to be effective in such cases. For this   //! reason, pike libraries should use dynamic resolution through e.g.   //! @expr{->@} or @expr{master()->resolv()@} instead.    + class Boolean + //! Common base class for @[Val.True] and @[Val.False], mainly to + //! facilitate typing. Do not create any instances of this. + { +  constant is_val_boolean = 1; +  //! Nonzero recognition constant that can be used to recognize both +  //! @[Val.true] and @[Val.false]. +  +  string encode_json(); + } +    class True   //! Type for the @[Val.true] object. Do not create more instances of   //! this - use @[Val.true] instead.   { -  +  inherit Boolean; +     constant is_val_true = 1;    //! Nonzero recognition constant.       string encode_json() {return "true";}       // The following shouldn't be necessary if there's only one    // instance, but that might not always be the case.    protected int __hash()    {return 34123;}    protected int `== (mixed other)
pike.git/lib/modules/Val.pmod:46:    protected string _sprintf (int flag)    {    return flag == 'O' && "Val.true";    }   }      class False   //! Type for the @[Val.false] object. Do not create more instances of   //! this - use @[Val.false] instead.   { +  inherit Boolean; +     constant is_val_false = 1;    //! Nonzero recognition constant.       protected int `!() {return 1;}       string encode_json() {return "false";}       protected int __hash()    {return 54634;}    protected int `== (mixed other)
pike.git/lib/modules/Val.pmod:73:    default: error ("Cannot cast %O to %s.\n", this, type);    }    }       protected string _sprintf (int flag)    {    return flag == 'O' && "Val.false";    }   }    - True true = True(); - False false = False(); + Boolean true = True(); + Boolean false = False();   //! Objects that represents the boolean values true and false. In a   //! boolean context these evaluate to true and false, respectively.   //!   //! They produce @expr{1@} and @expr{0@}, respectively, when cast to   //! integer, and @expr{"1"@} and @expr{"0"@} when cast to string. They   //! do however not compare as equal to the integers 1 and 0, or any   //! other values. @[Val.true] only compares (and hashes) as equal with   //! other instances of @[True] (although there should be as few as   //! possible). Similarly, @[Val.false] is only considered equal to   //! other @[False] instances.