equal
deleted
inserted
replaced
70 private: |
70 private: |
71 int m_index; |
71 int m_index; |
72 int m_last; |
72 int m_last; |
73 }; |
73 }; |
74 |
74 |
75 static qint32 toArrayIndex(const QString &str) |
|
76 { |
|
77 QByteArray bytes = str.toUtf8(); |
|
78 char *eptr; |
|
79 quint32 pos = strtoul(bytes.constData(), &eptr, 10); |
|
80 if ((eptr == bytes.constData() + bytes.size()) |
|
81 && (QByteArray::number(pos) == bytes)) { |
|
82 return pos; |
|
83 } |
|
84 return -1; |
|
85 } |
|
86 |
|
87 //! [0] |
75 //! [0] |
88 ByteArrayClass::ByteArrayClass(QScriptEngine *engine) |
76 ByteArrayClass::ByteArrayClass(QScriptEngine *engine) |
89 : QObject(engine), QScriptClass(engine) |
77 : QObject(engine), QScriptClass(engine) |
90 { |
78 { |
91 qScriptRegisterMetaType<QByteArray>(engine, toScriptValue, fromScriptValue); |
79 qScriptRegisterMetaType<QByteArray>(engine, toScriptValue, fromScriptValue); |
118 if (!ba) |
106 if (!ba) |
119 return 0; |
107 return 0; |
120 if (name == length) { |
108 if (name == length) { |
121 return flags; |
109 return flags; |
122 } else { |
110 } else { |
123 qint32 pos = toArrayIndex(name); |
111 bool isArrayIndex; |
124 if (pos == -1) |
112 qint32 pos = name.toArrayIndex(&isArrayIndex); |
|
113 if (!isArrayIndex) |
125 return 0; |
114 return 0; |
126 *id = pos; |
115 *id = pos; |
127 if ((flags & HandlesReadAccess) && (pos >= ba->size())) |
116 if ((flags & HandlesReadAccess) && (pos >= ba->size())) |
128 flags &= ~HandlesReadAccess; |
117 flags &= ~HandlesReadAccess; |
129 return flags; |
118 return flags; |