JSC::JSValue ScriptModuleLoader::evaluate(JSC::JSGlobalObject*, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue, JSC::JSValue moduleRecordValue, JSC::JSValue) { JSC::VM& vm = exec->vm(); auto scope = DECLARE_THROW_SCOPE(vm); // FIXME: Currently, we only support JSModuleRecord. // Once the reflective part of the module loader is supported, we will handle arbitrary values. // https://whatwg.github.io/loader/#registry-prototype-provide auto* moduleRecord = jsDynamicDowncast<JSC::JSModuleRecord*>(moduleRecordValue); if (!moduleRecord) return JSC::jsUndefined(); URL sourceURL; if (moduleKeyValue.isSymbol()) sourceURL = m_document.url(); else if (moduleKeyValue.isString()) sourceURL = URL(URL(), asString(moduleKeyValue)->value(exec)); else return JSC::throwTypeError(exec, scope, ASCIILiteral("Module key is not Symbol or String.")); if (!sourceURL.isValid()) return JSC::throwTypeError(exec, scope, ASCIILiteral("Module key is an invalid URL.")); if (auto* frame = m_document.frame()) return frame->script().evaluateModule(sourceURL, *moduleRecord); return JSC::jsUndefined(); }
PassRefPtr<ScriptCallStack> createScriptCallStackFromException(JSC::ExecState* exec, JSC::JSValue& exception, size_t maxStackSize) { Vector<ScriptCallFrame> frames; RefCountedArray<StackFrame> stackTrace = exec->vm().exceptionStack(); for (size_t i = 0; i < stackTrace.size() && i < maxStackSize; i++) { if (!stackTrace[i].callee && frames.size()) break; String functionName = stackTrace[i].friendlyFunctionName(exec); unsigned line; unsigned column; stackTrace[i].computeLineAndColumn(line, column); frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL, line, column)); } // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions // Fallback to getting at least the line and sourceURL from the exception if it has values and the exceptionStack doesn't. if (frames.size() > 0) { const ScriptCallFrame& firstCallFrame = frames.first(); JSObject* exceptionObject = exception.toObject(exec); if (exception.isObject() && firstCallFrame.sourceURL().isEmpty()) { JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line")); int lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0; JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL")); String exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined"); frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, lineNumber, 0); } } return ScriptCallStack::create(frames); }
String DragData::asURL(String* /*title*/) const { JSC::JSLock lock(false); bool success; JSC::JSValue data = m_platformDragData->getData(ClipboardApolloHelper::URI_LIST_TYPE, success); if (success && data.isString()) return String(ustringToString(data.toString(m_platformDragData->execState()))); return String(); }
wxString wxWebFrame::RunScript(const wxString& javascript) { wxString returnValue = wxEmptyString; if (m_impl->frame) { JSC::JSValue result = m_impl->frame->loader()->executeScript(javascript, true).jsValue(); if (result) returnValue = wxString(result.toString(m_impl->frame->script()->globalObject()->globalExec()).UTF8String().c_str(), wxConvUTF8); } return returnValue; }
/*! Returns the `this' object associated with this QScriptContext. */ QScriptValue QScriptContext::thisObject() const { JSC::CallFrame *frame = const_cast<JSC::ExecState*>(QScriptEnginePrivate::frameForContext(this)); QScriptEnginePrivate *engine = QScript::scriptEngineFromExec(frame); QScript::APIShim shim(engine); JSC::JSValue result = engine->thisForContext(frame); if (!result || result.isNull()) result = frame->globalThisValue(); return engine->scriptValueFromJSCValue(result); }
PassRefPtr<IDBKey> createIDBKeyFromValue(JSC::ExecState* exec, JSC::JSValue value) { if (value.isNull()) return IDBKey::create(); if (value.isInt32()) return IDBKey::create(value.toInt32(exec)); if (value.isString()) return IDBKey::create(ustringToString(value.toString(exec))); // FIXME: Implement dates. return 0; }
JSValue WebInjectedScriptHost::type(JSC::ExecState* exec, JSC::JSValue value) { if (value.inherits(JSNode::info())) return jsNontrivialString(exec, ASCIILiteral("node")); if (value.inherits(JSNodeList::info())) return jsNontrivialString(exec, ASCIILiteral("array")); if (value.inherits(JSHTMLCollection::info())) return jsNontrivialString(exec, ASCIILiteral("array")); return jsUndefined(); }
PassRefPtr<JSCustomXPathNSResolver> JSCustomXPathNSResolver::create(JSC::ExecState* exec, JSC::JSValue value) { if (value.isUndefinedOrNull()) return 0; JSObject* resolverObject = value.getObject(); if (!resolverObject) { setDOMException(exec, TYPE_MISMATCH_ERR); return 0; } return adoptRef(new JSCustomXPathNSResolver(resolverObject, asJSDOMWindow(exec->dynamicGlobalObject()))); }
JSValue WebInjectedScriptHost::subtype(JSC::ExecState* exec, JSC::JSValue value) { if (value.inherits(JSNode::info())) return jsNontrivialString(exec, ASCIILiteral("node")); if (value.inherits(JSNodeList::info())) return jsNontrivialString(exec, ASCIILiteral("array")); if (value.inherits(JSHTMLCollection::info())) return jsNontrivialString(exec, ASCIILiteral("array")); DOM_EXCEPTION_INTERFACES_FOR_EACH(RETURN_ERROR_IF_VALUE_INHERITS_EXCEPTION_TYPE) return jsUndefined(); }
ExceptionOr<Ref<FontFace>> FontFace::create(JSC::ExecState& state, Document& document, const String& family, JSC::JSValue source, const Descriptors& descriptors) { auto result = adoptRef(*new FontFace(document.fontSelector())); bool dataRequiresAsynchronousLoading = true; auto setFamilyResult = result->setFamily(family); if (setFamilyResult.hasException()) return setFamilyResult.releaseException(); if (source.isString()) { auto value = FontFace::parseString(source.getString(&state), CSSPropertySrc); if (!is<CSSValueList>(value.get())) return Exception { SYNTAX_ERR }; CSSFontFace::appendSources(result->backing(), downcast<CSSValueList>(*value), &document, false); } else if (auto arrayBufferView = toUnsharedArrayBufferView(source)) dataRequiresAsynchronousLoading = populateFontFaceWithArrayBuffer(result->backing(), arrayBufferView.releaseNonNull()); else if (auto arrayBuffer = toUnsharedArrayBuffer(source)) { auto arrayBufferView = JSC::Uint8Array::create(arrayBuffer, 0, arrayBuffer->byteLength()); dataRequiresAsynchronousLoading = populateFontFaceWithArrayBuffer(result->backing(), arrayBufferView.releaseNonNull()); } // These ternaries match the default strings inside the FontFaceDescriptors dictionary inside FontFace.idl. auto setStyleResult = result->setStyle(descriptors.style.isEmpty() ? ASCIILiteral("normal") : descriptors.style); if (setStyleResult.hasException()) return setStyleResult.releaseException(); auto setWeightResult = result->setWeight(descriptors.weight.isEmpty() ? ASCIILiteral("normal") : descriptors.weight); if (setWeightResult.hasException()) return setWeightResult.releaseException(); auto setStretchResult = result->setStretch(descriptors.stretch.isEmpty() ? ASCIILiteral("normal") : descriptors.stretch); if (setStretchResult.hasException()) return setStretchResult.releaseException(); auto setUnicodeRangeResult = result->setUnicodeRange(descriptors.unicodeRange.isEmpty() ? ASCIILiteral("U+0-10FFFF") : descriptors.unicodeRange); if (setUnicodeRangeResult.hasException()) return setUnicodeRangeResult.releaseException(); auto setVariantResult = result->setVariant(descriptors.variant.isEmpty() ? ASCIILiteral("normal") : descriptors.variant); if (setVariantResult.hasException()) return setVariantResult.releaseException(); auto setFeatureSettingsResult = result->setFeatureSettings(descriptors.featureSettings.isEmpty() ? ASCIILiteral("normal") : descriptors.featureSettings); if (setFeatureSettingsResult.hasException()) return setFeatureSettingsResult.releaseException(); if (!dataRequiresAsynchronousLoading) { result->backing().load(); ASSERT(result->backing().status() == CSSFontFace::Status::Success); } return WTFMove(result); }
CloneSerializer(ExecState* exec, MessagePortArray* messagePorts, Vector<uint8_t>& out) : CloneBase(exec) , m_buffer(out) , m_emptyIdentifier(exec, UString("", 0)) { write(CurrentVersion); if (messagePorts) { JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()); for (size_t i = 0; i < messagePorts->size(); i++) { JSC::JSValue value = toJS(exec, globalObject, messagePorts->at(i).get()); if (value.getObject()) m_transferredMessagePorts.add(value.getObject(), i); } } }
JSValueRef DumpRenderTreeSupportEfl::computedStyleIncludingVisitedInfo(JSContextRef context, JSValueRef value) { if (!value) return JSValueMakeUndefined(context); JSC::ExecState* exec = toJS(context); JSC::JSValue jsValue = toJS(exec, value); if (!jsValue.inherits(&WebCore::JSElement::s_info)) return JSValueMakeUndefined(context); WebCore::JSElement* jsElement = static_cast<WebCore::JSElement*>(asObject(jsValue)); WebCore::Element* element = jsElement->impl(); RefPtr<WebCore::CSSComputedStyleDeclaration> style = WebCore::CSSComputedStyleDeclaration::create(element, true); return toRef(exec, toJS(exec, jsElement->globalObject(), style.get())); }
void fillMessagePortArray(JSC::ExecState* exec, JSC::JSValue value, MessagePortArray& portArray) { // Convert from the passed-in JS array-like object to a MessagePortArray. // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec. if (value.isUndefinedOrNull()) { portArray.resize(0); return; } // Validation of sequence types, per WebIDL spec 4.1.13. unsigned length; JSObject* object = toJSSequence(exec, value, length); if (exec->hadException()) return; portArray.resize(length); for (unsigned i = 0 ; i < length; ++i) { JSValue value = object->get(exec, i); if (exec->hadException()) return; // Validation of non-null objects, per HTML5 spec 8.3.3. if (value.isUndefinedOrNull()) { setDOMException(exec, INVALID_STATE_ERR); return; } // Validation of Objects implementing an interface, per WebIDL spec 4.1.15. RefPtr<MessagePort> port = toMessagePort(value); if (!port) { throwTypeError(exec); return; } portArray[i] = port.release(); } }
bool toVector(JSC::ExecState* exec, JSC::JSValue value, Vector<T, inlineCapacity>& vector) { if (!value.isObject()) return false; JSC::JSObject* object = asObject(value); int32_t length = object->get(exec, JSC::Identifier(exec, "length")).toInt32(exec); vector.resize(length); for (int32_t i = 0; i < length; ++i) { JSC::JSValue v = object->get(exec, i); if (exec->hadException()) return false; vector[i] = static_cast<T>(v.toNumber(exec)); } return true; }
wxString wxWebFrame::RunScript(const wxString& javascript) { wxString returnValue = wxEmptyString; if (m_impl->frame && m_impl->frame->loader()) { bool hasLoaded = m_impl->frame->loader()->frameHasLoaded(); wxASSERT_MSG(hasLoaded, wxT("Document must be loaded before calling RunScript.")); if (hasLoaded) { WebCore::ScriptController* controller = m_impl->frame->script(); bool jsEnabled = controller->canExecuteScripts(WebCore::AboutToExecuteScript); wxASSERT_MSG(jsEnabled, wxT("RunScript requires JavaScript to be enabled.")); if (jsEnabled) { JSC::JSValue result = controller->executeScript(javascript, true).jsValue(); if (result) returnValue = wxString(result.toString(m_impl->frame->script()->globalObject(WebCore::mainThreadNormalWorld())->globalExec()).utf8().data(), wxConvUTF8); } } } return returnValue; }
bool toVector(JSC::ExecState& state, JSC::JSValue value, Vector<T, inlineCapacity>& vector) { if (!value.isObject()) return false; JSC::JSObject* object = asObject(value); int32_t length = object->get(&state, state.vm().propertyNames->length).toInt32(&state); if (!vector.tryReserveCapacity(length)) return false; vector.resize(length); for (int32_t i = 0; i < length; ++i) { JSC::JSValue v = object->get(&state, i); if (state.hadException()) return false; vector[i] = static_cast<T>(v.toNumber(&state)); } return true; }
static JSC::JSValue JSC_HOST_CALL variantProtoFuncToString(JSC::ExecState *exec, JSC::JSObject *callee, JSC::JSValue thisValue, const JSC::ArgList &args) { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); thisValue = engine->toUsableValue(thisValue); if (!thisValue.inherits(&QScriptObject::info)) return throwError(exec, JSC::TypeError, "This object is not a QVariant"); QScriptObjectDelegate *delegate = static_cast<QScriptObject*>(JSC::asObject(thisValue))->delegate(); if (!delegate || (delegate->type() != QScriptObjectDelegate::Variant)) return throwError(exec, JSC::TypeError, "This object is not a QVariant"); const QVariant &v = static_cast<QVariantDelegate*>(delegate)->value(); JSC::UString result; JSC::JSValue value = variantProtoFuncValueOf(exec, callee, thisValue, args); if (value.isObject()) { result = v.toString(); if (result.isEmpty() && !v.canConvert(QVariant::String)) result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(v.typeName())); } else { result = value.toString(exec); } return JSC::jsString(exec, result); }
bool WebFrame::stringByEvaluatingJavaScriptInScriptWorld(WebScriptWorld* world, void* jsGlobalObject, const char* script, const char** evaluationResult) { if (!world || !jsGlobalObject || !evaluationResult) return false; *evaluationResult = 0; Frame* coreFrame = core(this); JSObjectRef globalObjectRef = reinterpret_cast<JSObjectRef>(jsGlobalObject); String string = String(script); // Start off with some guess at a frame and a global object, we'll try to do better...! JSDOMWindow* anyWorldGlobalObject = coreFrame->script()->globalObject(mainThreadNormalWorld()); // The global object is probably a shell object? - if so, we know how to use this! JSC::JSObject* globalObjectObj = toJS(globalObjectRef); if (!strcmp(globalObjectObj->classInfo()->className, "JSDOMWindowShell")) anyWorldGlobalObject = static_cast<JSDOMWindowShell*>(globalObjectObj)->window(); // Get the frame from the global object we've settled on. Frame* frame = anyWorldGlobalObject->impl()->frame(); ASSERT(frame->document()); JSC::JSValue result = frame->script()->executeScriptInWorld(world->world(), string, true).jsValue(); if (!frame) // In case the script removed our frame from the page. return true; // This bizarre set of rules matches behavior from WebKit for Safari 2.0. // If you don't like it, use -[WebScriptObject evaluateWebScript:] or // JSEvaluateScript instead, since they have less surprising semantics. if (!result || !result.isBoolean() && !result.isString() && !result.isNumber()) return true; JSC::JSLock lock(JSC::SilenceAssertionsOnly); String resultString = ustringToString(result.toString(anyWorldGlobalObject->globalExec())); *evaluationResult = strdup(resultString.utf8().data()); return true; }
void fillMessagePortArray(JSC::ExecState* exec, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers) { // Convert from the passed-in JS array-like object to a MessagePortArray. // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec. if (value.isUndefinedOrNull()) { portArray.resize(0); arrayBuffers.resize(0); return; } // Validation of sequence types, per WebIDL spec 4.1.13. unsigned length = 0; JSObject* object = toJSSequence(exec, value, length); if (exec->hadException()) return; for (unsigned i = 0 ; i < length; ++i) { JSValue value = object->get(exec, i); if (exec->hadException()) return; // Validation of non-null objects, per HTML5 spec 10.3.3. if (value.isUndefinedOrNull()) { setDOMException(exec, INVALID_STATE_ERR); return; } // Validation of Objects implementing an interface, per WebIDL spec 4.1.15. RefPtr<MessagePort> port = toMessagePort(value); if (port) { // Check for duplicate ports. if (portArray.contains(port)) { #if MODIFY(ENGINE) //[2014.03.05][infraware][jungong16] : fix to issue. http://www.w3.org/TR/webmessaging/#dom-window-postmessage setDOMException(exec, DATA_CLONE_ERR); #else setDOMException(exec, INVALID_STATE_ERR); #endif return; } portArray.append(port.release()); } else { RefPtr<ArrayBuffer> arrayBuffer = toArrayBuffer(value); if (arrayBuffer) arrayBuffers.append(arrayBuffer); else { throwTypeError(exec); return; } } } }
String DragData::asPlainText() const { JSC::JSLock lock(false); bool success; JSC::JSValue data = m_platformDragData->getData(ClipboardApolloHelper::TEXT_TYPE, success); if (success && data.isString()) return String(ustringToString(data.toString(m_platformDragData->execState()))); Vector<String> filenames; asFilenames(filenames); if (!filenames.isEmpty()) { String result; for (unsigned int i=0; i<filenames.size(); i++) result.append(filenames[i] + "\n"); return result; } String url(asURL(NULL)); if (!url.isEmpty()) return url; return String(); }
void selectIndexSetter(HTMLSelectElement* select, JSC::ExecState* exec, unsigned index, JSC::JSValue value) { if (value.isUndefinedOrNull()) select->removeByIndex(index); else { ExceptionCode ec = 0; HTMLOptionElement* option = toHTMLOptionElement(value); if (!option) ec = TYPE_MISMATCH_ERR; else select->setOption(index, option, ec); setDOMException(exec, ec); } }
JSC::JSValue JSModuleLoader::evaluate(JSC::JSGlobalObject*, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue, JSC::JSValue moduleRecordValue) { // FIXME: Currently, we only support JSModuleRecord. // Once the reflective part of the module loader is supported, we will handle arbitrary values. // https://whatwg.github.io/loader/#registry-prototype-provide JSC::JSModuleRecord* moduleRecord = JSC::jsDynamicCast<JSC::JSModuleRecord*>(moduleRecordValue); if (!moduleRecord) return JSC::jsUndefined(); URL sourceUrl; if (moduleKeyValue.isSymbol()) sourceUrl = m_document.url(); else if (moduleKeyValue.isString()) sourceUrl = URL(URL(), asString(moduleKeyValue)->value(exec)); else return JSC::throwTypeError(exec, ASCIILiteral("Module key is not Symbol or String.")); if (!sourceUrl.isValid()) return JSC::throwTypeError(exec, ASCIILiteral("Module key is an invalid URL.")); // FIXME: Implement evaluating module code. return JSC::jsUndefined(); }
void toArray(JSC::ExecState* exec, JSC::JSValue value, T*& array, int& size) { array = 0; if (!value.isObject()) return; JSC::JSObject* object = asObject(value); int length = object->get(exec, JSC::Identifier(exec, "length")).toInt32(exec); void* tempValues; if (!tryFastMalloc(length * sizeof(T)).getValue(tempValues)) return; T* values = static_cast<T*>(tempValues); for (int i = 0; i < length; ++i) { JSC::JSValue v = object->get(exec, i); if (exec->hadException()) return; values[i] = static_cast<T>(v.toNumber(exec)); } array = values; size = length; }
static bool buildOptions(FetchRequest::InternalRequest& request, ScriptExecutionContext& context, const Dictionary& init) { JSC::JSValue window; if (init.get("window", window)) { if (!window.isNull()) return false; } if (!setReferrer(request, context, init)) return false; String value; if (init.get("referrerPolicy", value) && !setReferrerPolicy(request.options, value)) return false; if (init.get("mode", value) && !setMode(request.options, value)) return false; if (request.options.mode() == FetchOptions::Mode::Navigate) return false; if (init.get("credentials", value) && !setCredentials(request.options, value)) return false; if (init.get("cache", value) && !setCache(request.options, value)) return false; if (init.get("redirect", value) && !setRedirect(request.options, value)) return false; init.get("integrity", request.integrity); if (init.get("method", value) && !setMethod(request.request, value)) return false; return true; }
void fillMessagePortArray(JSC::ExecState* exec, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers) { // Convert from the passed-in JS array-like object to a MessagePortArray. // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec. if (value.isUndefinedOrNull()) { portArray.resize(0); arrayBuffers.resize(0); return; } // Validation of sequence types, per WebIDL spec 4.1.13. unsigned length = 0; JSObject* object = toJSSequence(exec, value, length); if (exec->hadException()) return; for (unsigned i = 0 ; i < length; ++i) { JSValue value = object->get(exec, i); if (exec->hadException()) return; // Validation of non-null objects, per HTML5 spec 10.3.3. if (value.isUndefinedOrNull()) { setDOMException(exec, INVALID_STATE_ERR); return; } // Validation of Objects implementing an interface, per WebIDL spec 4.1.15. RefPtr<MessagePort> port = JSMessagePort::toWrapped(value); if (port) { // Check for duplicate ports. if (portArray.contains(port)) { setDOMException(exec, INVALID_STATE_ERR); return; } portArray.append(port.release()); } else { RefPtr<ArrayBuffer> arrayBuffer = toArrayBuffer(value); if (arrayBuffer) arrayBuffers.append(arrayBuffer); else { throwTypeError(exec); return; } } } }
JSType JSValueGetType(JSContextRef, JSValueRef value) { JSC::JSValue* jsValue = toJS(value); if (jsValue->isUndefined()) return kJSTypeUndefined; if (jsValue->isNull()) return kJSTypeNull; if (jsValue->isBoolean()) return kJSTypeBoolean; if (jsValue->isNumber()) return kJSTypeNumber; if (jsValue->isString()) return kJSTypeString; ASSERT(jsValue->isObject()); return kJSTypeObject; }
void DragData::asFilenames(Vector<String>& result) const { bool success; JSC::JSValue data = m_platformDragData->getData(ClipboardApolloHelper::FILE_LIST_TYPE, success); JSC::ExecState *exec = m_platformDragData->execState(); if (success && data.isObject()) { JSC::JSObject* filenameArray = data.toObject(exec); uint32_t length = filenameArray->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec); for (uint32_t i=0; i<length; i++) { JSC::JSValue fileValue = filenameArray->get(exec, i); if (fileValue.isObject()) { JSC::JSObject* file = fileValue.toObject(exec); JSC::JSValue pathValue = file->get(exec, JSC::Identifier(exec, "nativePath")); if (pathValue.isString()) { String path = ustringToString(pathValue.toString(exec)); result.append(path); } } } } if (exec->hadException()) exec->clearException(); }
JSType JSValueGetType(JSContextRef ctx, JSValueRef value) { JSC::ExecState* exec = toJS(ctx); exec->globalData().heap.registerThread(); JSC::JSLock lock(exec); JSC::JSValue jsValue = toJS(exec, value); if (jsValue.isUndefined()) return kJSTypeUndefined; if (jsValue.isNull()) return kJSTypeNull; if (jsValue.isBoolean()) return kJSTypeBoolean; if (jsValue.isNumber()) return kJSTypeNumber; if (jsValue.isString()) return kJSTypeString; ASSERT(jsValue.isObject()); return kJSTypeObject; }
static JSC::JSValue JSC_HOST_CALL variantProtoFuncValueOf(JSC::ExecState *exec, JSC::JSObject*, JSC::JSValue thisValue, const JSC::ArgList&) { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); thisValue = engine->toUsableValue(thisValue); if (!thisValue.inherits(&QScriptObject::info)) return throwError(exec, JSC::TypeError); QScriptObjectDelegate *delegate = static_cast<QScriptObject*>(JSC::asObject(thisValue))->delegate(); if (!delegate || (delegate->type() != QScriptObjectDelegate::Variant)) return throwError(exec, JSC::TypeError); const QVariant &v = static_cast<QVariantDelegate*>(delegate)->value(); switch (v.type()) { case QVariant::Invalid: return JSC::jsUndefined(); case QVariant::String: return JSC::jsString(exec, v.toString()); case QVariant::Int: return JSC::jsNumber(exec, v.toInt()); case QVariant::Bool: return JSC::jsBoolean(v.toBool()); case QVariant::Double: return JSC::jsNumber(exec, v.toDouble()); // case QVariant::Char: // return JSC::jsNumber(exec, v.toChar().unicode()); case QVariant::UInt: return JSC::jsNumber(exec, v.toUInt()); default: ; } return thisValue; }
void JSUint32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) { impl()->set(index, static_cast<unsigned int>(value.toUInt32(exec))); }