本文整理汇总了C++中StringRef::getPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::getPointer方法的具体用法?C++ StringRef::getPointer怎么用?C++ StringRef::getPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringRef
的用法示例。
在下文中一共展示了StringRef::getPointer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: query
PropertyAttributes Object::query(const Managed *m, StringRef name)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
return queryIndexed(m, idx);
const Object *o = static_cast<const Object *>(m);
idx = o->internalClass->find(name.getPointer());
if (idx < UINT_MAX)
return o->internalClass->propertyData[idx];
return Attr_Invalid;
}
示例2: insertMember
void Object::insertMember(const StringRef s, const Property &p, PropertyAttributes attributes)
{
uint idx;
InternalClass::addMember(this, s.getPointer(), attributes, &idx);
ensureMemberIndex(internalClass->size);
if (attributes.isAccessor()) {
hasAccessorProperty = 1;
Property *pp = propertyAt(idx);
pp->value = p.value;
pp->set = p.set;
} else {
memberData[idx] = p.value;
}
}
示例3: internalGet
// Section 8.12.3
ReturnedValue Object::internalGet(const StringRef name, bool *hasProperty)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
return getIndexed(idx, hasProperty);
name->makeIdentifier();
Object *o = this;
while (o) {
uint idx = o->internalClass->find(name.getPointer());
if (idx < UINT_MAX) {
if (hasProperty)
*hasProperty = true;
return getValue(o->propertyAt(idx), o->internalClass->propertyData.at(idx));
}
o = o->prototype();
}
if (hasProperty)
*hasProperty = false;
return Encode::undefined();
}
示例4: __defineOwnProperty__
bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const StringRef member, const Property &p, PropertyAttributes attrs)
{
// clause 5
if (attrs.isEmpty())
return true;
Property *current;
PropertyAttributes cattrs;
if (!member.isNull()) {
current = propertyAt(index);
cattrs = internalClass->propertyData[index];
} else {
current = arrayData->getProperty(index);
cattrs = arrayData->attributes(index);
}
// clause 6
if (p.isSubset(attrs, *current, cattrs))
return true;
// clause 7
if (!cattrs.isConfigurable()) {
if (attrs.isConfigurable())
goto reject;
if (attrs.hasEnumerable() && attrs.isEnumerable() != cattrs.isEnumerable())
goto reject;
}
// clause 8
if (attrs.isGeneric() || current->value.isEmpty())
goto accept;
// clause 9
if (cattrs.isData() != attrs.isData()) {
// 9a
if (!cattrs.isConfigurable())
goto reject;
if (cattrs.isData()) {
// 9b
cattrs.setType(PropertyAttributes::Accessor);
cattrs.clearWritable();
if (member.isNull()) {
// need to convert the array and the slot
initSparseArray();
setArrayAttributes(index, cattrs);
current = arrayData->getProperty(index);
}
current->setGetter(0);
current->setSetter(0);
} else {
// 9c
cattrs.setType(PropertyAttributes::Data);
cattrs.setWritable(false);
if (member.isNull()) {
// need to convert the array and the slot
setArrayAttributes(index, cattrs);
current = arrayData->getProperty(index);
}
current->value = Primitive::undefinedValue();
}
} else if (cattrs.isData() && attrs.isData()) { // clause 10
if (!cattrs.isConfigurable() && !cattrs.isWritable()) {
if (attrs.isWritable() || !current->value.sameValue(p.value))
goto reject;
}
} else { // clause 10
Q_ASSERT(cattrs.isAccessor() && attrs.isAccessor());
if (!cattrs.isConfigurable()) {
if (!p.value.isEmpty() && current->value.val != p.value.val)
goto reject;
if (!p.set.isEmpty() && current->set.val != p.set.val)
goto reject;
}
}
accept:
current->merge(cattrs, p, attrs);
if (!member.isNull()) {
InternalClass::changeMember(this, member.getPointer(), cattrs);
} else {
setArrayAttributes(index, cattrs);
}
if (cattrs.isAccessor())
hasAccessorProperty = 1;
return true;
reject:
if (ctx->strictMode)
ctx->throwTypeError();
return false;
}
示例5: internalPut
// Section 8.12.5
void Object::internalPut(const StringRef name, const ValueRef value)
{
if (internalClass->engine->hasException)
return;
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
return putIndexed(idx, value);
name->makeIdentifier();
uint member = internalClass->find(name.getPointer());
Property *pd = 0;
PropertyAttributes attrs;
if (member < UINT_MAX) {
pd = propertyAt(member);
attrs = internalClass->propertyData[member];
}
// clause 1
if (pd) {
if (attrs.isAccessor()) {
if (pd->setter())
goto cont;
goto reject;
} else if (!attrs.isWritable())
goto reject;
else if (isArrayObject() && name->equals(engine()->id_length)) {
bool ok;
uint l = value->asArrayLength(&ok);
if (!ok) {
engine()->currentContext()->throwRangeError(value);
return;
}
ok = setArrayLength(l);
if (!ok)
goto reject;
} else {
pd->value = *value;
}
return;
} else if (!prototype()) {
if (!extensible)
goto reject;
} else {
// clause 4
if ((pd = prototype()->__getPropertyDescriptor__(name, &attrs))) {
if (attrs.isAccessor()) {
if (!pd->setter())
goto reject;
} else if (!extensible || !attrs.isWritable()) {
goto reject;
}
} else if (!extensible) {
goto reject;
}
}
cont:
// Clause 5
if (pd && attrs.isAccessor()) {
assert(pd->setter() != 0);
Scope scope(engine());
ScopedCallData callData(scope, 1);
callData->args[0] = *value;
callData->thisObject = this;
pd->setter()->call(callData);
return;
}
insertMember(name, value);
return;
reject:
if (engine()->currentContext()->strictMode) {
QString message = QStringLiteral("Cannot assign to read-only property \"");
message += name->toQString();
message += QLatin1Char('\"');
engine()->currentContext()->throwTypeError(message);
}
}
示例6: find
uint InternalClass::find(const StringRef string)
{
return find(string.getPointer());
}
示例7: addMember
void InternalClass::addMember(Object *object, StringRef string, PropertyAttributes data, uint *index)
{
return addMember(object, string.getPointer(), data, index);
}