// Allocates memory void growable_array::append(array* elts_) { factor_vm* parent = elements.parent; data_root<array> elts(elts_, parent); cell capacity = array_capacity(elts.untagged()); if (count + capacity > array_capacity(elements.untagged())) { reallot_array(2 * (count + capacity)); } for (cell index = 0; index < capacity; index++) parent->set_array_nth(elements.untagged(), count++, array_nth(elts.untagged(), index)); }
QScriptValueImpl RegExp::method_exec(QScriptContextPrivate *context, QScriptEnginePrivate *eng, QScriptClassInfo *classInfo) { QScriptValueImpl self = context->thisObject(); if (self.classInfo() != classInfo) { return throwThisObjectTypeError( context, QLatin1String("RegExp.prototype.exec")); } Instance *rx_data = Instance::get(self, classInfo); Q_ASSERT(rx_data != 0); QString S = context->argument(0).toString(); int length = S.length(); QScriptValueImpl lastIndex = self.property(QLatin1String("lastIndex")); int i = lastIndex.isValid() ? int (lastIndex.toInteger()) : 0; bool global = self.property(QLatin1String("global")).toBoolean(); if (! global) i = 0; if (i < 0 || i >= length) return (eng->nullValue()); #ifndef QT_NO_REGEXP int index = rx_data->value.indexIn(S, i); if (index == -1) #endif // QT_NO_REGEXP return eng->nullValue(); #ifndef QT_NO_REGEXP int e = index + rx_data->value.matchedLength(); if (global) self.setProperty(QLatin1String("lastIndex"), QScriptValueImpl(e)); QScript::Array elts(eng); QStringList capturedTexts = rx_data->value.capturedTexts(); for (int i = 0; i < capturedTexts.count(); ++i) elts.assign(i, QScriptValueImpl(eng, capturedTexts.at(i))); QScriptValueImpl r = eng->newArray(elts); r.setProperty(QLatin1String("index"), QScriptValueImpl(index)); r.setProperty(QLatin1String("input"), QScriptValueImpl(eng, S)); return r; #endif // QT_NO_REGEXP }
WordVector& WordVector::operator=(const WordVector& a) { long i, n; _ntl_ulong *p; const _ntl_ulong *ap; if (this == &a) return *this; n = a.length(); ap = a.elts(); SetLength(n); p = elts(); for (i = 0; i < n; i++) p[i] = ap[i]; return *this; }
void visit(V v)const { auto p=elts(); for(ngx_uint_t i=0;i<size();i++) v(p[i]); }
T& operator[](ngx_uint_t i)const { NgxException::require(i<size()&&get()); return elts()[i]; }