Qt 4.8
Namespaces | Classes | Functions
QDeclarativeJS Namespace Reference

Namespaces

 AST
 
 Ecma
 

Classes

class  DiagnosticMessage
 
class  Engine
 
class  Lexer
 
class  MemoryPool
 
class  NameId
 
class  NodePool
 
class  Parser
 
class  TextWriter
 

Functions

double integerFromString (const char *buf, int size, int radix)
 
double integerFromString (const QString &str, int radix)
 
template<typename NodeType >
NodeType * makeAstNode (MemoryPool *storage)
 
template<typename NodeType , typename Arg1 >
NodeType * makeAstNode (MemoryPool *storage, Arg1 arg1)
 
template<typename NodeType , typename Arg1 , typename Arg2 >
NodeType * makeAstNode (MemoryPool *storage, Arg1 arg1, Arg2 arg2)
 
template<typename NodeType , typename Arg1 , typename Arg2 , typename Arg3 >
NodeType * makeAstNode (MemoryPool *storage, Arg1 arg1, Arg2 arg2, Arg3 arg3)
 
template<typename NodeType , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 >
NodeType * makeAstNode (MemoryPool *storage, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
 
QString numberToString (double value)
 
uint qHash (const QDeclarativeJS::NameId &id)
 
static int toDigit (char c)
 

Function Documentation

◆ integerFromString() [1/2]

double QDeclarativeJS::integerFromString ( const char *  buf,
int  size,
int  radix 
)

Definition at line 114 of file qdeclarativejsengine_p.cpp.

Referenced by integerFromString(), and QDeclarativeJS::Lexer::lex().

115 {
116  if (size == 0)
117  return qSNaN();
118 
119  double sign = 1.0;
120  int i = 0;
121  if (buf[0] == '+') {
122  ++i;
123  } else if (buf[0] == '-') {
124  sign = -1.0;
125  ++i;
126  }
127 
128  if (((size-i) >= 2) && (buf[i] == '0')) {
129  if (((buf[i+1] == 'x') || (buf[i+1] == 'X'))
130  && (radix < 34)) {
131  if ((radix != 0) && (radix != 16))
132  return 0;
133  radix = 16;
134  i += 2;
135  } else {
136  if (radix == 0) {
137  radix = 8;
138  ++i;
139  }
140  }
141  } else if (radix == 0) {
142  radix = 10;
143  }
144 
145  int j = i;
146  for ( ; i < size; ++i) {
147  int d = toDigit(buf[i]);
148  if ((d == -1) || (d >= radix))
149  break;
150  }
151  double result;
152  if (j == i) {
153  if (!qstrcmp(buf, "Infinity"))
154  result = qInf();
155  else
156  result = qSNaN();
157  } else {
158  result = 0;
159  double multiplier = 1;
160  for (--i ; i >= j; --i, multiplier *= radix)
161  result += toDigit(buf[i]) * multiplier;
162  }
163  result *= sign;
164  return result;
165 }
double d
Definition: qnumeric_p.h:62
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
Definition: qbytearray.cpp:231
static int sign(int x)
Q_CORE_EXPORT double qSNaN()
Returns the bit pattern of a signalling NaN as a double.
Definition: qnumeric.cpp:80
Q_CORE_EXPORT double qInf()
Returns the bit pattern for an infinite number as a double.
Definition: qnumeric.cpp:90
static int toDigit(char c)

◆ integerFromString() [2/2]

double QDeclarativeJS::integerFromString ( const QString str,
int  radix 
)

Definition at line 167 of file qdeclarativejsengine_p.cpp.

168 {
169  QByteArray ba = str.trimmed().toLatin1();
170  return integerFromString(ba.constData(), ba.size(), radix);
171 }
double integerFromString(const QString &str, int radix)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ makeAstNode() [1/5]

template<typename NodeType >
NodeType* QDeclarativeJS::makeAstNode ( MemoryPool storage)
inline

Definition at line 75 of file qdeclarativejsnodepool_p.h.

76 {
77  NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType();
78  return node;
79 }

◆ makeAstNode() [2/5]

template<typename NodeType , typename Arg1 >
NodeType* QDeclarativeJS::makeAstNode ( MemoryPool storage,
Arg1  arg1 
)
inline

Definition at line 82 of file qdeclarativejsnodepool_p.h.

83 {
84  NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1);
85  return node;
86 }

◆ makeAstNode() [3/5]

template<typename NodeType , typename Arg1 , typename Arg2 >
NodeType* QDeclarativeJS::makeAstNode ( MemoryPool storage,
Arg1  arg1,
Arg2  arg2 
)
inline

Definition at line 89 of file qdeclarativejsnodepool_p.h.

90 {
91  NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2);
92  return node;
93 }

◆ makeAstNode() [4/5]

template<typename NodeType , typename Arg1 , typename Arg2 , typename Arg3 >
NodeType* QDeclarativeJS::makeAstNode ( MemoryPool storage,
Arg1  arg1,
Arg2  arg2,
Arg3  arg3 
)
inline

Definition at line 96 of file qdeclarativejsnodepool_p.h.

97 {
98  NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2, arg3);
99  return node;
100 }

◆ makeAstNode() [5/5]

template<typename NodeType , typename Arg1 , typename Arg2 , typename Arg3 , typename Arg4 >
NodeType* QDeclarativeJS::makeAstNode ( MemoryPool storage,
Arg1  arg1,
Arg2  arg2,
Arg3  arg3,
Arg4  arg4 
)
inline

Definition at line 103 of file qdeclarativejsnodepool_p.h.

104 {
105  NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2, arg3, arg4);
106  return node;
107 }

◆ numberToString()

QString QDeclarativeJS::numberToString ( double  value)

Definition at line 57 of file qdeclarativejsengine_p.cpp.

58 { return QString::number(value); }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448

◆ qHash()

uint QDeclarativeJS::qHash ( const QDeclarativeJS::NameId id)

Definition at line 54 of file qdeclarativejsengine_p.cpp.

Referenced by QDeclarativeJS::NameId::operator<().

55 { return qHash(id.asString()); }
uint qHash(const QUrl &url)
Definition: qurl.h:285

◆ toDigit()

static int QDeclarativeJS::toDigit ( char  c)
static

Definition at line 103 of file qdeclarativejsengine_p.cpp.

Referenced by integerFromString().

104 {
105  if ((c >= '0') && (c <= '9'))
106  return c - '0';
107  else if ((c >= 'a') && (c <= 'z'))
108  return 10 + c - 'a';
109  else if ((c >= 'A') && (c <= 'Z'))
110  return 10 + c - 'A';
111  return -1;
112 }
unsigned char c[8]
Definition: qnumeric_p.h:62