本文整理汇总了C++中PropertySlot::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertySlot::getValue方法的具体用法?C++ PropertySlot::getValue怎么用?C++ PropertySlot::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertySlot
的用法示例。
在下文中一共展示了PropertySlot::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOwnPropertyDescriptor
bool JSNPObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSNPObject* thisObject = jsCast<JSNPObject*>(object);
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
if (!thisObject->m_npObject) {
throwInvalidAccessError(exec);
return false;
}
NPIdentifier npIdentifier = npIdentifierFromIdentifier(propertyName);
// Calling NPClass::invoke will call into plug-in code, and there's no telling what the plug-in can do.
// (including destroying the plug-in). Because of this, we make sure to keep the plug-in alive until
// the call has finished.
NPRuntimeObjectMap::PluginProtector protector(thisObject->m_objectMap);
// First, check if the NPObject has a property with this name.
if (thisObject->m_npObject->_class->hasProperty && thisObject->m_npObject->_class->hasProperty(thisObject->m_npObject, npIdentifier)) {
PropertySlot slot;
slot.setCustom(thisObject, propertyGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete);
return true;
}
// Second, check if the NPObject has a method with this name.
if (thisObject->m_npObject->_class->hasMethod && thisObject->m_npObject->_class->hasMethod(thisObject->m_npObject, npIdentifier)) {
PropertySlot slot;
slot.setCustom(thisObject, methodGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
return true;
}
return false;
}
示例2: getOwnPropertyDescriptor
bool JSCSSStyleDeclaration::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
ASSERT_GC_OBJECT_INHERITS(this, &s_info);
const HashEntry* entry = JSCSSStyleDeclarationTable.entry(exec, propertyName);
if (entry) {
PropertySlot slot;
slot.setCustom(this, entry->propertyGetter());
descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
return true;
}
bool ok;
unsigned index = propertyName.toUInt32(ok);
if (ok && index < static_cast<CSSStyleDeclaration*>(impl())->length()) {
PropertySlot slot;
slot.setCustomIndex(this, index, indexGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
return true;
}
if (canGetItemsForName(exec, static_cast<CSSStyleDeclaration*>(impl()), propertyName)) {
PropertySlot slot;
slot.setCustom(this, nameGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
return true;
}
return getStaticValueDescriptor<JSCSSStyleDeclaration, Base>(exec, &JSCSSStyleDeclarationTable, this, propertyName, descriptor);
}
示例3: getOwnPropertyDescriptor
bool JSTestEventTarget::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSTestEventTarget* thisObject = jsCast<JSTestEventTarget*>(object);
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
const HashEntry* entry = JSTestEventTargetTable.entry(exec, propertyName);
if (entry) {
PropertySlot slot;
slot.setCustom(thisObject, entry->propertyGetter());
descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
return true;
}
unsigned index = propertyName.asIndex();
if (index != PropertyName::NotAnIndex && index < static_cast<TestEventTarget*>(thisObject->impl())->length()) {
PropertySlot slot;
slot.setCustomIndex(thisObject, index, indexGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
return true;
}
if (canGetItemsForName(exec, static_cast<TestEventTarget*>(thisObject->impl()), propertyName)) {
PropertySlot slot;
slot.setCustom(thisObject, nameGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
return true;
}
return getStaticValueDescriptor<JSTestEventTarget, Base>(exec, &JSTestEventTargetTable, thisObject, propertyName, descriptor);
}
示例4: getOwnPropertyDescriptor
bool JSNamedNodeMap::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
ASSERT_GC_OBJECT_INHERITS(this, &s_info);
JSValue proto = prototype();
if (proto.isObject() && static_cast<JSObject*>(asObject(proto))->hasProperty(exec, propertyName))
return false;
const HashEntry* entry = JSNamedNodeMapTable.entry(exec, propertyName);
if (entry) {
PropertySlot slot;
slot.setCustom(this, entry->propertyGetter());
descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
return true;
}
bool ok;
unsigned index = propertyName.toUInt32(ok);
if (ok && index < static_cast<NamedNodeMap*>(impl())->length()) {
PropertySlot slot;
slot.setCustomIndex(this, index, indexGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
return true;
}
if (canGetItemsForName(exec, static_cast<NamedNodeMap*>(impl()), propertyName)) {
PropertySlot slot;
slot.setCustom(this, nameGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
return true;
}
return getStaticValueDescriptor<JSNamedNodeMap, Base>(exec, &JSNamedNodeMapTable, this, propertyName, descriptor);
}
示例5: getOwnPropertySlot
bool DebuggerScope::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
DebuggerScope* scope = jsCast<DebuggerScope*>(object);
ASSERT(scope->isValid());
if (!scope->isValid())
return false;
JSObject* thisObject = JSScope::objectAtScope(scope->jsScope());
slot.setThisValue(JSValue(thisObject));
// By default, JSObject::getPropertySlot() will look in the DebuggerScope's prototype
// chain and not the wrapped scope, and JSObject::getPropertySlot() cannot be overridden
// to behave differently for the DebuggerScope.
//
// Instead, we'll treat all properties in the wrapped scope and its prototype chain as
// the own properties of the DebuggerScope. This is fine because the WebInspector
// does not presently need to distinguish between what's owned at each level in the
// prototype chain. Hence, we'll invoke getPropertySlot() on the wrapped scope here
// instead of getOwnPropertySlot().
bool result = thisObject->getPropertySlot(exec, propertyName, slot);
if (result && slot.isValue() && slot.getValue(exec, propertyName) == jsTDZValue()) {
// FIXME:
// We hit a scope property that has the TDZ empty value.
// Currently, we just lie to the inspector and claim that this property is undefined.
// This is not ideal and we should fix it.
// https://bugs.webkit.org/show_bug.cgi?id=144977
slot.setValue(slot.slotBase(), DontEnum, jsUndefined());
return true;
}
return result;
}
示例6:
static JSValue *getProperty(ExecState *exec, JSObject *obj, unsigned index)
{
PropertySlot slot;
if (!obj->getPropertySlot(exec, index, slot))
return NULL;
return slot.getValue(exec, obj, index);
}
示例7: getOwnPropertyDescriptorDelegate
bool JSHistory::getOwnPropertyDescriptorDelegate(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
if (!impl()->frame()) {
descriptor.setUndefined();
return true;
}
// Throw out all cross domain access
if (!allowAccessToFrame(exec, impl()->frame()))
return true;
// Check for the few functions that we allow, even when called cross-domain.
const HashEntry* entry = JSHistoryPrototype::s_info.propHashTable(exec)->entry(exec, propertyName);
if (entry) {
PropertySlot slot;
// Allow access to back(), forward() and go() from any frame.
if (entry->attributes() & JSC::Function) {
if (entry->function() == jsHistoryPrototypeFunctionBack) {
slot.setCustom(this, nonCachingStaticBackFunctionGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
return true;
} else if (entry->function() == jsHistoryPrototypeFunctionForward) {
slot.setCustom(this, nonCachingStaticForwardFunctionGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
return true;
} else if (entry->function() == jsHistoryPrototypeFunctionGo) {
slot.setCustom(this, nonCachingStaticGoFunctionGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
return true;
}
}
} else {
// Allow access to toString() cross-domain, but always Object.toString.
if (propertyName == exec->propertyNames().toString) {
PropertySlot slot;
slot.setCustom(this, objectToStringFunctionGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
return true;
}
}
descriptor.setUndefined();
return true;
}
示例8: getOwnPropertyDescriptor
bool JSHTMLDocument::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
if (canGetItemsForName(exec, static_cast<HTMLDocument*>(impl()), propertyName)) {
PropertySlot slot;
slot.setCustom(this, nameGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
return true;
}
return getStaticValueDescriptor<JSHTMLDocument, Base>(exec, &JSHTMLDocumentTable, this, propertyName, descriptor);
}
示例9: getOwnPropertyDescriptor
bool JSEntryArray::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
const HashEntry* entry = JSEntryArrayTable.entry(exec, propertyName);
if (entry) {
PropertySlot slot;
slot.setCustom(this, entry->propertyGetter());
descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
return true;
}
bool ok;
unsigned index = propertyName.toUInt32(ok);
if (ok && index < static_cast<EntryArray*>(impl())->length()) {
PropertySlot slot;
slot.setCustomIndex(this, index, indexGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
return true;
}
return getStaticValueDescriptor<JSEntryArray, Base>(exec, getJSEntryArrayTable(exec), this, propertyName, descriptor);
}
示例10: getOwnPropertyDescriptor
bool RuntimeMethod::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor &descriptor)
{
if (propertyName == exec->propertyNames().length) {
PropertySlot slot;
slot.setCustom(this, lengthGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
return true;
}
return InternalFunction::getOwnPropertyDescriptor(exec, propertyName, descriptor);
}
示例11: getOwnPropertyDescriptor
bool RuntimeArray::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
RuntimeArray* thisObject = jsCast<RuntimeArray*>(object);
if (propertyName == exec->propertyNames().length) {
PropertySlot slot;
slot.setCustom(thisObject, lengthGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
return true;
}
unsigned index = propertyName.asIndex();
if (index < thisObject->getLength()) {
ASSERT(index != PropertyName::NotAnIndex);
PropertySlot slot;
slot.setCustomIndex(thisObject, index, indexGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | DontEnum);
return true;
}
return JSObject::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
示例12: getOwnPropertyDescriptor
bool RuntimeArray::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
if (propertyName == exec->propertyNames().length) {
PropertySlot slot;
slot.setCustom(this, lengthGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
return true;
}
bool ok;
unsigned index = propertyName.toArrayIndex(ok);
if (ok) {
if (index < getLength()) {
PropertySlot slot;
slot.setCustomIndex(this, index, indexGetter);
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | DontEnum);
return true;
}
}
return JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
}
示例13: runtimeObjectCustomGetOwnPropertyDescriptor
bool runtimeObjectCustomGetOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, JSHTMLElement* element)
{
RuntimeObjectImp* runtimeObject = getRuntimeObject(exec, element->impl());
if (!runtimeObject)
return false;
if (!runtimeObject->hasProperty(exec, propertyName))
return false;
PropertySlot slot;
slot.setCustom(element, runtimeObjectPropertyGetter);
// While we don't know what the plugin allows, we do know that we prevent
// enumeration or deletion of properties, so we mark plugin properties
// as DontEnum | DontDelete
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontEnum | DontDelete);
return true;
}
示例14: getByIndex
JSValue* JSValue::getByIndex(ExecState* exec, unsigned propertyName) const
{
switch (type()) {
case StringType: {
UString s = static_cast<const StringImp*>(asCell())->value();
if (propertyName < static_cast<unsigned>(s.size())) {
return jsString(s.substr(propertyName, 1));
}
// fall through
}
default: {
JSObject* obj = toObject(exec);
PropertySlot slot;
if (obj->getPropertySlot(exec, propertyName, slot))
return slot.getValue(exec, obj, propertyName);
return jsUndefined();
}
}
}
示例15: getOwnPropertySlot
// Property access sequence is:
// (1) indexed properties,
// (2) regular own properties,
// (3) named properties (in fact, these shouldn't be on the window, should be on the NPO).
bool JSDOMWindow::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
{
// (1) First, indexed properties.
// Hand off all indexed access to getOwnPropertySlotByIndex, which supports the indexed getter.
if (Optional<unsigned> index = parseIndex(propertyName))
return getOwnPropertySlotByIndex(object, state, index.value(), slot);
auto* thisObject = jsCast<JSDOMWindow*>(object);
auto* frame = thisObject->wrapped().frame();
// Hand off all cross-domain/frameless access to jsDOMWindowGetOwnPropertySlotRestrictedAccess.
String errorMessage;
if (!frame || !BindingSecurity::shouldAllowAccessToDOMWindow(*state, thisObject->wrapped(), errorMessage))
return jsDOMWindowGetOwnPropertySlotRestrictedAccess(thisObject, frame, state, propertyName, slot, errorMessage);
// FIXME: this need more explanation.
// (Particularly, is it correct that this exists here but not in getOwnPropertySlotByIndex?)
slot.setWatchpointSet(thisObject->m_windowCloseWatchpoints);
// (2) Regular own properties.
PropertySlot slotCopy = slot;
if (Base::getOwnPropertySlot(thisObject, state, propertyName, slot)) {
// Detect when we're getting the property 'showModalDialog', this is disabled, and has its original value.
bool isShowModalDialogAndShouldHide = propertyName == state->propertyNames().showModalDialog
&& !DOMWindow::canShowModalDialog(frame)
&& slot.isValue() && isHostFunction(slot.getValue(state, propertyName), jsDOMWindowInstanceFunctionShowModalDialog);
// Unless we're in the showModalDialog special case, we're done.
if (!isShowModalDialogAndShouldHide)
return true;
slot = slotCopy;
}
#if ENABLE(USER_MESSAGE_HANDLERS)
if (propertyName == state->propertyNames().webkit && thisObject->wrapped().shouldHaveWebKitNamespaceForWorld(thisObject->world())) {
slot.setCacheableCustom(thisObject, DontDelete | ReadOnly, jsDOMWindowWebKit);
return true;
}
#endif
return false;
}