B2G/gecko/dom/mobilemessage/src/ril/WspPduHelper.jsm
/**
   * @param data
   *        A wrapped object containing raw PDU data.
   *
   * @return Binary encoded version number.
   */
@param data
A wrapped object containing raw PDU data.

@return Binary encoded version number.
@param data A wrapped object containing raw PDU data . @return Binary encoded version number .
function decode(data) {
    let begin = data.offset;
    let value;
    try {
      value = ShortInteger.decode(data);
      if ((value >= 0x10) && (value < 0x80)) {
        return value;
      }
      throw new CodeError("Version-value: invalid value " + value);
    } catch (e) {}
    data.offset = begin;
    let str = TextString.decode(data);
    if (!str.match(/^[1-7](\.1?\d)?$/)) {
      throw new CodeError("Version-value: invalid value " + str);
    }
    let major = str.charCodeAt(0) - 0x30;
    let minor = 0x0F;
    if (str.length > 1) {
      minor = str.charCodeAt(2) - 0x30;
      if (str.length > 3) {
        minor = 10 + (str.charCodeAt(3) - 0x30);
        if (minor > 14) {
          throw new CodeError("Version-value: invalid minor " + minor);
        }
      }
    }
    return major << 4 | minor;
  }
function decode ( data ) { let begin = data . offset ; let value ; try { value = ShortInteger . decode ( data ) ; if ( ( value >= 0x10 ) && ( value < 0x80 ) ) { return value ; } throw new CodeError ( "Version-value: invalid value " + value ) ; } catch ( e ) { } data . offset = begin ; let str = TextString . decode ( data ) ; if ( ! str . match ( / ^[1-7](\.1?\d)?$ / ) ) { throw new CodeError ( "Version-value: invalid value " + str ) ; } let major = str . charCodeAt ( 0 ) - 0x30 ; let minor = 0x0F ; if ( str . length > 1 ) { minor = str . charCodeAt ( 2 ) - 0x30 ; if ( str . length > 3 ) { minor = 10 + ( str . charCodeAt ( 3 ) - 0x30 ) ; if ( minor > 14 ) { throw new CodeError ( "Version-value: invalid minor " + minor ) ; } } } return major << 4 | minor ; }
@param data
        A wrapped object containing raw PDU data.
@param data A wrapped object containing raw PDU data .