本文整理汇总了C++中JSValue::toUInt32方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::toUInt32方法的具体用法?C++ JSValue::toUInt32怎么用?C++ JSValue::toUInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSValue
的用法示例。
在下文中一共展示了JSValue::toUInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setJSHTMLSelectElementLength
void setJSHTMLSelectElementLength(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLSelectElement* castedThis = static_cast<JSHTMLSelectElement*>(thisObject);
HTMLSelectElement* imp = static_cast<HTMLSelectElement*>(castedThis->impl());
ExceptionCode ec = 0;
imp->setLength(value.toUInt32(exec), ec);
setDOMException(exec, ec);
}
示例2: encode
static inline EncodedJSValue JSC_HOST_CALL arrayIteratorNext(CallFrame* callFrame)
{
JSArrayIterator* iterator = jsDynamicCast<JSArrayIterator*>(callFrame->thisValue());
if (!iterator) {
ASSERT_NOT_REACHED();
return JSValue::encode(throwTypeError(callFrame, ASCIILiteral("Cannot call ArrayIterator.next() on a non-ArrayIterator object")));
}
JSObject* iteratedObject = iterator->iteratedObject();
size_t index = iterator->nextIndex();
ArrayIterationKind kind = iterator->iterationKind();
JSValue jsLength = JSValue(iteratedObject).get(callFrame, callFrame->propertyNames().length);
if (callFrame->hadException())
return JSValue::encode(jsNull());
size_t length = jsLength.toUInt32(callFrame);
if (callFrame->hadException())
return JSValue::encode(jsNull());
if (index >= length) {
iterator->finish();
return createIteratorResult(callFrame, kind, index, jsUndefined(), true);
}
if (JSValue result = iteratedObject->tryGetIndexQuickly(index)) {
iterator->setNextIndex(index + 1);
return createIteratorResult(callFrame, kind, index, result, false);
}
JSValue result = jsUndefined();
PropertySlot slot(iteratedObject);
if (kind > ArrayIterateSparseTag) {
// We assume that the indexed property will be an own property so cache the getOwnProperty
// method locally
auto getOwnPropertySlotByIndex = iteratedObject->methodTable()->getOwnPropertySlotByIndex;
while (index < length) {
if (getOwnPropertySlotByIndex(iteratedObject, callFrame, index, slot)) {
result = slot.getValue(callFrame, index);
break;
}
if (iteratedObject->getPropertySlot(callFrame, index, slot)) {
result = slot.getValue(callFrame, index);
break;
}
index++;
}
} else if (iteratedObject->getPropertySlot(callFrame, index, slot))
result = slot.getValue(callFrame, index);
if (index == length)
iterator->finish();
else
iterator->setNextIndex(index + 1);
return createIteratorResult(callFrame, kind, index, jsUndefined(), index == length);
}
示例3: executeSql
JSValue JSSQLTransactionSync::executeSql(ExecState* exec)
{
if (!exec->argumentCount()) {
setDOMException(exec, SYNTAX_ERR);
return jsUndefined();
}
String sqlStatement = ustringToString(exec->argument(0).toString(exec));
if (exec->hadException())
return jsUndefined();
// Now assemble the list of SQL arguments
Vector<SQLValue> sqlValues;
if (!exec->argument(1).isUndefinedOrNull()) {
JSObject* object = exec->argument(1).getObject();
if (!object) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
JSValue lengthValue = object->get(exec, exec->propertyNames().length);
if (exec->hadException())
return jsUndefined();
unsigned length = lengthValue.toUInt32(exec);
if (exec->hadException())
return jsUndefined();
for (unsigned i = 0 ; i < length; ++i) {
JSValue value = object->get(exec, i);
if (exec->hadException())
return jsUndefined();
if (value.isUndefinedOrNull())
sqlValues.append(SQLValue());
else if (value.isNumber())
sqlValues.append(value.uncheckedGetNumber());
else {
// Convert the argument to a string and append it
sqlValues.append(ustringToString(value.toString(exec)));
if (exec->hadException())
return jsUndefined();
}
}
}
ExceptionCode ec = 0;
JSValue result = toJS(exec, globalObject(), WTF::getPtr(m_impl->executeSQL(sqlStatement, sqlValues, ec)));
setDOMException(exec, ec);
return result;
}
示例4: put
// ECMA 15.4.5.1
void JSArray::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
JSArray* thisObject = jsCast<JSArray*>(cell);
if (propertyName == exec->propertyNames().length) {
unsigned newLength = value.toUInt32(exec);
if (value.toNumber(exec) != static_cast<double>(newLength)) {
exec->vm().throwException(exec, createRangeError(exec, ASCIILiteral("Invalid array length")));
return;
}
thisObject->setLength(exec, newLength, slot.isStrictMode());
return;
}
JSObject::put(thisObject, exec, propertyName, value, slot);
}
示例5: put
// ECMA 15.4.5.1
void JSArray::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
bool isArrayIndex;
unsigned i = propertyName.toArrayIndex(&isArrayIndex);
if (isArrayIndex) {
put(exec, i, value);
return;
}
if (propertyName == exec->propertyNames().length) {
unsigned newLength = value.toUInt32(exec);
if (value.toNumber(exec) != static_cast<double>(newLength)) {
throwError(exec, RangeError, "Invalid array length.");
return;
}
setLength(newLength);
return;
}
JSObject::put(exec, propertyName, value, slot);
}
示例6: toJSSequence
JSC::JSObject* toJSSequence(ExecState* exec, JSValue value, unsigned& length)
{
JSObject* object = value.getObject();
if (!object) {
throwTypeError(exec);
return 0;
}
JSValue lengthValue = object->get(exec, exec->propertyNames().length);
if (exec->hadException())
return 0;
if (lengthValue.isUndefinedOrNull()) {
throwTypeError(exec);
return 0;
}
length = lengthValue.toUInt32(exec);
if (exec->hadException())
return 0;
return object;
}
示例7: create
static PassRefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValue* value)
{
if (!value->isObject())
return 0;
JSObject* object = asObject(value);
JSValue* enableHighAccuracyValue = object->get(exec, Identifier(exec, "enableHighAccuracy"));
if (exec->hadException())
return 0;
bool enableHighAccuracy = enableHighAccuracyValue->toBoolean(exec);
if (exec->hadException())
return 0;
JSValue* timeoutValue = object->get(exec, Identifier(exec, "timeout"));
if (exec->hadException())
return 0;
unsigned timeout = timeoutValue->toUInt32(exec);
if (exec->hadException())
return 0;
return PositionOptions::create(enableHighAccuracy, timeout);
}
示例8: setDistanceModel
void JSPannerNode::setDistanceModel(ExecState* exec, JSValue value)
{
PannerNode& imp = impl();
#if ENABLE(LEGACY_WEB_AUDIO)
if (value.isNumber()) {
uint32_t model = value.toUInt32(exec);
if (!imp.setDistanceModel(model))
exec->vm().throwException(exec, createTypeError(exec, "Illegal distanceModel"));
return;
}
#endif
if (value.isString()) {
String model = value.toString(exec)->value(exec);
if (model == "linear" || model == "inverse" || model == "exponential") {
imp.setDistanceModel(model);
return;
}
}
exec->vm().throwException(exec, createTypeError(exec, "Illegal distanceModel"));
}
示例9: setPanningModel
void JSPannerNode::setPanningModel(ExecState* exec, JSValue value)
{
PannerNode& imp = impl();
#if ENABLE(LEGACY_WEB_AUDIO)
if (value.isNumber()) {
uint32_t model = value.toUInt32(exec);
if (!imp.setPanningModel(model))
exec->vm().throwException(exec, createTypeError(exec, "Illegal panningModel"));
return;
}
#endif
if (value.isString()) {
String model = value.toString(exec)->value(exec);
if (model == "equalpower" || model == "HRTF" || model == "soundfield") {
imp.setPanningModel(model);
return;
}
}
exec->vm().throwException(exec, createTypeError(exec, "Illegal panningModel"));
}
示例10: setType
void JSOscillatorNode::setType(ExecState* exec, JSValue value)
{
OscillatorNode& imp = impl();
#if ENABLE(LEGACY_WEB_AUDIO)
if (value.isNumber()) {
uint32_t type = value.toUInt32(exec);
if (!imp.setType(type))
exec->vm().throwException(exec, createTypeError(exec, "Illegal OscillatorNode type"));
return;
}
#endif
if (value.isString()) {
String type = value.toString(exec)->value(exec);
if (type == "sine" || type == "square" || type == "sawtooth" || type == "triangle") {
imp.setType(type);
return;
}
}
exec->vm().throwException(exec, createTypeError(exec, "Illegal OscillatorNode type"));
}
示例11: setJSHTMLMarqueeElementVspace
void setJSHTMLMarqueeElementVspace(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLMarqueeElement* castedThis = static_cast<JSHTMLMarqueeElement*>(thisObject);
HTMLMarqueeElement* imp = static_cast<HTMLMarqueeElement*>(castedThis->impl());
imp->setUnsignedIntegralAttribute(WebCore::HTMLNames::vspaceAttr, value.toUInt32(exec));
}
示例12: setJSAudioPannerNodeDistanceModel
void setJSAudioPannerNodeDistanceModel(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSAudioPannerNode* castedThis = static_cast<JSAudioPannerNode*>(thisObject);
AudioPannerNode* imp = static_cast<AudioPannerNode*>(castedThis->impl());
imp->setDistanceModel(value.toUInt32(exec));
}
示例13: convertValue
void JSDictionary::convertValue(ExecState* exec, JSValue value, unsigned long& result)
{
result = static_cast<unsigned long>(value.toUInt32(exec));
}
示例14: executeSql
JSValue JSSQLTransaction::executeSql(ExecState* exec)
{
if (!exec->argumentCount()) {
setDOMException(exec, SYNTAX_ERR);
return jsUndefined();
}
String sqlStatement = exec->argument(0).toString(exec)->value(exec);
if (exec->hadException())
return jsUndefined();
// Now assemble the list of SQL arguments
Vector<SQLValue> sqlValues;
if (!exec->argument(1).isUndefinedOrNull()) {
JSObject* object = exec->argument(1).getObject();
if (!object) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
JSValue lengthValue = object->get(exec, exec->propertyNames().length);
if (exec->hadException())
return jsUndefined();
unsigned length = lengthValue.toUInt32(exec);
if (exec->hadException())
return jsUndefined();
for (unsigned i = 0 ; i < length; ++i) {
JSValue value = object->get(exec, i);
if (exec->hadException())
return jsUndefined();
if (value.isUndefinedOrNull())
sqlValues.append(SQLValue());
else if (value.isNumber())
sqlValues.append(value.asNumber());
else {
// Convert the argument to a string and append it
sqlValues.append(value.toString(exec)->value(exec));
if (exec->hadException())
return jsUndefined();
}
}
}
RefPtr<SQLStatementCallback> callback;
if (!exec->argument(2).isUndefinedOrNull()) {
JSObject* object = exec->argument(2).getObject();
if (!object) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
callback = JSSQLStatementCallback::create(object, jsCast<JSDOMGlobalObject*>(globalObject()));
}
RefPtr<SQLStatementErrorCallback> errorCallback;
if (!exec->argument(3).isUndefinedOrNull()) {
JSObject* object = exec->argument(3).getObject();
if (!object) {
setDOMException(exec, TYPE_MISMATCH_ERR);
return jsUndefined();
}
errorCallback = JSSQLStatementErrorCallback::create(object, jsCast<JSDOMGlobalObject*>(globalObject()));
}
ExceptionCode ec = 0;
m_impl->executeSQL(sqlStatement, sqlValues, callback.release(), errorCallback.release(), ec);
setDOMException(exec, ec);
return jsUndefined();
}
示例15: setJSSVGZoomAndPanZoomAndPan
void setJSSVGZoomAndPanZoomAndPan(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSSVGZoomAndPan* castedThis = static_cast<JSSVGZoomAndPan*>(thisObject);
SVGZoomAndPan* imp = static_cast<SVGZoomAndPan*>(castedThis->impl());
imp->setZoomAndPan(value.toUInt32(exec));
}