gecko-dev/content/smil/nsSMILParserUtils.h
Ehsan Akhgari e368dc9c85 Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00

107 lines
4.4 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef NS_SMILPARSERUTILS_H_
#define NS_SMILPARSERUTILS_H_
#include "nscore.h"
#include "nsTArray.h"
#include "nsString.h"
class nsISMILAttr;
class nsISMILAnimationElement;
class nsSMILTimeValue;
class nsSMILValue;
class nsSMILRepeatCount;
class nsSMILTimeValueSpecParams;
/**
* Common parsing utilities for the SMIL module. There is little re-use here; it
* simply serves to simplify other classes by moving parsing outside and to aid
* unit testing.
*/
class nsSMILParserUtils
{
public:
// Abstract helper-class for assisting in parsing |values| attribute
class GenericValueParser {
public:
virtual nsresult Parse(const nsAString& aValueStr) = 0;
};
static nsresult ParseKeySplines(const nsAString& aSpec,
nsTArray<double>& aSplineArray);
// Used for parsing the |keyTimes| and |keyPoints| attributes.
static nsresult ParseSemicolonDelimitedProgressList(const nsAString& aSpec,
bool aNonDecreasing,
nsTArray<double>& aArray);
static nsresult ParseValues(const nsAString& aSpec,
const nsISMILAnimationElement* aSrcElement,
const nsISMILAttr& aAttribute,
nsTArray<nsSMILValue>& aValuesArray,
bool& aPreventCachingOfSandwich);
// Generic method that will run some code on each sub-section of an animation
// element's "values" list.
static nsresult ParseValuesGeneric(const nsAString& aSpec,
GenericValueParser& aParser);
static nsresult ParseRepeatCount(const nsAString& aSpec,
nsSMILRepeatCount& aResult);
static nsresult ParseTimeValueSpecParams(const nsAString& aSpec,
nsSMILTimeValueSpecParams& aResult);
// Used with ParseClockValue. Allow + or - before a clock value.
static const int8_t kClockValueAllowSign = 1;
// Used with ParseClockValue. Allow "indefinite" in a clock value
static const int8_t kClockValueAllowIndefinite = 2;
/*
* This method can actually parse more than a clock value as defined in the
* SMIL Animation specification. It can also parse:
* - the + or - before an offset
* - the special value "indefinite"
* - the special value "media"
*
* Because the value "media" cannot be represented as part of an
* nsSMILTimeValue and has different meanings depending on where it is used,
* it is passed out as a separate parameter (which can be set to nullptr if the
* media attribute is not allowed).
*
* @param aSpec The string containing a clock value, e.g. "10s"
* @param aResult The parsed result. May be NULL (e.g. if this method is
* being called just to test if aSpec is a valid clock value).
* [OUT]
* @param aFlags A combination of the kClockValue* bit flags OR'ed together
* to define what additional syntax is allowed.
* @param aIsMedia Optional out parameter which, if not null, will be set to
* true if the value is the string "media", false
* otherwise. If it is null, the string "media" is not
* allowed.
*
* @return NS_OK if aSpec was successfully parsed as a valid clock value
* (according to aFlags), an error code otherwise.
*/
static nsresult ParseClockValue(const nsAString& aSpec,
nsSMILTimeValue* aResult,
uint32_t aFlags = 0,
bool* aIsMedia = nullptr);
/*
* This method checks whether the given string looks like a negative number.
* Specifically, it checks whether the string looks matches the pattern
* "[whitespace]*-[numeral].*" If the string matches this pattern, this
* method returns the index of the first character after the '-' sign
* (i.e. the index of the absolute value). If not, this method returns -1.
*/
static int32_t CheckForNegativeNumber(const nsAString& aStr);
};
#endif // NS_SMILPARSERUTILS_H_