本文整理汇总了C++中AvmCore::uintToAtom方法的典型用法代码示例。如果您正苦于以下问题:C++ AvmCore::uintToAtom方法的具体用法?C++ AvmCore::uintToAtom怎么用?C++ AvmCore::uintToAtom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AvmCore
的用法示例。
在下文中一共展示了AvmCore::uintToAtom方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filter
Atom VectorBaseObject::filter(ScriptObject *callback, Atom thisObject)
{
AvmCore* core = this->core();
VectorBaseObject *r = newVector();
if (!callback)
return r->atom();
ScriptObject *d = this;
uint32 len = m_length;
// If thisObject is null, the call function will substitute the global object
Atom args[4] = { thisObject, nullObjectAtom, nullObjectAtom, this->atom() };
for (uint32 i = 0, k = 0; i < len; i++)
{
args[1] = d->getUintProperty (i); // element
args[2] = core->uintToAtom (i); // index
Atom result = callback->call(3, args);
if (result == trueAtom)
{
r->setUintProperty (k++, args[1]);
}
}
return r->atom();
}
示例2: filter
Atom VectorBaseObject::filter(ScriptObject *callback, Atom thisObject)
{
AvmCore* core = this->core();
VectorBaseObject *r = newVector();
if (!callback)
return r->atom();
ScriptObject *d = this;
uint32 len = m_length;
for (uint32 i = 0, k = 0; i < len; i++)
{
// If thisObject is null, the call function will substitute the global object
// args are modified in place by callee
Atom element = d->getUintProperty(i);
Atom args[4] = {
thisObject,
element,
core->uintToAtom(i), // index
this->atom()
};
Atom result = callback->call(3, args);
if (result == trueAtom)
r->setUintProperty(k++, element);
}
return r->atom();
}
示例3: setLengthProperty
void ScriptObject::setLengthProperty(uint32_t newLen)
{
Toplevel* toplevel = this->toplevel();
AvmCore* core = toplevel->core();
Multiname mname(core->getAnyPublicNamespace(), core->klength);
Atom lenAtm = core->uintToAtom(newLen);
toplevel->setproperty(this->atom(), &mname, lenAtm, this->vtable);
}
示例4: getUintProperty
Atom ScriptObject::getUintProperty(uint32_t i) const
{
// N.B.: a key present in ScriptObject must be interned string;
// thus uninterned implies absent (cf. bugzilla 556023).
AvmCore* core = this->core();
if (!(i&MAX_INTEGER_MASK))
{
if (!traits()->needsHashtable())
{
Stringp interned;
bool present = core->isInternedUint(i, &interned);
if (present)
{
Atom name = interned->atom();
return getAtomPropertyFromProtoChain(name, delegate,
traits());
}
else
{
return undefinedAtom;
}
}
else
{
// dynamic lookup on this object
Atom name = core->uintToAtom (i);
const ScriptObject *o = this;
do
{
// ensure prototype is dynamic
if (!o->vtable->traits->getHashtableOffset())
continue;
Atom const value = o->getTable()->getNonEmpty(name);
if (!InlineHashtable::isEmpty(value))
return value;
}
while ((o = o->delegate) != NULL);
return undefinedAtom;
}
}
else
{
Stringp interned;
bool present;
present = core->isInternedUint(i, &interned);
if (present)
{
return getAtomProperty(interned->atom());
}
else
{
return undefinedAtom;
}
}
}
示例5: _replace
Stringp StringClass::_replace(Stringp subject, Atom pattern, Atom replacementAtom)
{
AvmCore* core = this->core();
ScriptObject *replaceFunction = NULL;
Stringp replacement = NULL;
if (AvmCore::istype(replacementAtom, core->traits.function_itraits)) {
replaceFunction = AvmCore::atomToScriptObject(replacementAtom);
} else {
replacement = core->string(replacementAtom);
}
if (AvmCore::istype(pattern, core->traits.regexp_itraits)) {
// RegExp mode
RegExpObject *reObj = (RegExpObject*) core->atomToScriptObject(pattern);
if (replaceFunction) {
return core->string(reObj->replace(subject, replaceFunction));
} else {
return core->string(reObj->replace(subject, replacement));
}
} else {
// String replace mode
Stringp searchString = core->string(pattern);
int index = subject->indexOf(searchString);
if (index == -1) {
// Search string not found; return input unchanged.
return subject;
}
if (replaceFunction) {
// Invoke the replacement function to figure out the
// replacement string
Atom argv[4] = { undefinedAtom,
searchString->atom(),
core->uintToAtom(index),
subject->atom() };
replacement = core->string(toplevel()->op_call(replaceFunction->atom(),
3, argv));
}
Stringp out = subject->substring(0, index);
out = String::concatStrings(out, replacement);
out = String::concatStrings(out, subject->substring(index + searchString->length(), subject->length()));
return out;
}
}
示例6: hasUintProperty
bool ScriptObject::hasUintProperty(uint32_t i) const
{
AvmCore* core = this->core();
if (!(i&MAX_INTEGER_MASK))
{
Atom name = core->uintToAtom (i);
if (traits()->needsHashtable())
{
return getTable()->contains(name);
}
else
{
// ISSUE should this walk the proto chain?
return false;
}
}
else
{
return hasAtomProperty(core->internUint32(i)->atom());
}
}
示例7: delUintProperty
bool ScriptObject::delUintProperty(uint32_t i)
{
AvmCore* core = this->core();
if (!(i&MAX_INTEGER_MASK))
{
Atom name = core->uintToAtom (i);
if (traits()->needsHashtable())
{
getTable()->remove(name);
return true;
}
else
{
return false;
}
}
else
{
return deleteAtomProperty(core->internUint32(i)->atom());
}
}
示例8: setUintProperty
void ScriptObject::setUintProperty(uint32_t i, Atom value)
{
AvmCore* core = this->core();
if (!(i&MAX_INTEGER_MASK))
{
Atom name = core->uintToAtom (i);
if (traits()->needsHashtable())
{
MMGC_MEM_TYPE(this);
getTable()->add(name, value);
MMGC_MEM_TYPE(NULL);
}
else
{
throwWriteSealedError(core->internUint32(i)->atom());
}
}
else
{
setAtomProperty(core->internUint32(i)->atom(), value);
}
}