2008-10-18 Darin Adler <darin@apple.com>
Reviewed by Oliver Hunt.
- next step of https://bugs.webkit.org/show_bug.cgi?id=21732
improve performance by eliminating JSValue as a base class for JSCell
Tweak a little more to get closer to where we can make JSValuePtr a class.
* API/APICast.h:
(toJS): Change back to JSValue* here, since we're converting the
pointer type.
* VM/CTI.cpp:
(JSC::CTI::unlinkCall): Call asPointer.
* VM/CTI.h: Cast to JSValue* here, since it's a pointer cast.
* kjs/DebuggerCallFrame.h:
(JSC::DebuggerCallFrame::DebuggerCallFrame): Call noValue.
* kjs/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData): Call noValue.
* kjs/JSImmediate.cpp:
(JSC::JSImmediate::toObject): Remove unneeded const_cast.
* kjs/JSWrapperObject.h:
(JSC::JSWrapperObject::JSWrapperObject): Call noValue.
JavaScriptGlue:
2008-10-18 Darin Adler <darin@apple.com>
Reviewed by Oliver Hunt.
- next step of https://bugs.webkit.org/show_bug.cgi?id=21732
improve performance by eliminating JSValue as a base class for JSCell
Tweak a little more to get closer to where we can make JSValuePtr a class.
* JSObject.cpp:
(nativeCallFunction): Call asObject.
* JSUtils.cpp:
(KJSValueToJSObject): Use JSValuePtr and asObject.
(JSObjectKJSValue): Ditto.
(KJSValueToCFTypeInternal): Ditto.
(KJSValueToCFType): Ditto.
* JSUtils.h: Ditto.
* UserObjectImp.cpp:
(UserObjectImp::callAsFunction): Use JSValuePtr and asObject.
(UserObjectImp::userObjectGetter): Ditto.
(UserObjectImp::getOwnPropertySlot): Ditto.
(UserObjectImp::put): Ditto.
(UserObjectImp::toPrimitive): Ditto.
* UserObjectImp.h: Ditto.
WebCore:
2008-10-18 Darin Adler <darin@apple.com>
Reviewed by Oliver Hunt.
- next step of https://bugs.webkit.org/show_bug.cgi?id=21732
improve performance by eliminating JSValue as a base class for JSCell
Tweak a little more to get closer to where we can make JSValuePtr a class.
* bindings/js/JSAudioConstructor.cpp:
(WebCore::JSAudioConstructor::JSAudioConstructor): Use asObject.
(WebCore::constructAudio): Ditto.
* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::nameGetter): Ditto.
* bindings/js/JSCanvasRenderingContext2DCustom.cpp:
(WebCore::toHTMLCanvasStyle): Use asString and asObject.
(WebCore::JSCanvasRenderingContext2D::setFillColor): Ditto.
(WebCore::JSCanvasRenderingContext2D::setStrokeColor): Ditto.
(WebCore::JSCanvasRenderingContext2D::drawImage): Ditto.
(WebCore::JSCanvasRenderingContext2D::drawImageFromRect): Ditto.
(WebCore::JSCanvasRenderingContext2D::setShadow): Ditto.
(WebCore::JSCanvasRenderingContext2D::createPattern): Ditto.
* bindings/js/JSCustomSQLTransactionErrorCallback.cpp:
(WebCore::JSCustomSQLTransactionErrorCallback::handleEvent): Use JSValuePtr.
* bindings/js/JSDOMBinding.cpp:
(WebCore::setDOMException): Use noValue.
* bindings/js/JSDOMBinding.h:
(WebCore::getDOMPrototype): Use asObject.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::showModalDialog): Use noValue.
(jsDOMWindowBaseEvent): Use asObject.
(jsDOMWindowBaseImage): Ditto.
(jsDOMWindowBaseMessageChannel): Ditto.
(jsDOMWindowBaseOption): Ditto.
(jsDOMWindowBaseXMLHttpRequest): Ditto.
(jsDOMWindowBaseAudio): Ditto.
(jsDOMWindowBaseXSLTProcessor): Ditto.
(WebCore::JSDOMWindowBase::childFrameGetter): Ditto.
(WebCore::JSDOMWindowBase::indexGetter): Ditto.
(WebCore::JSDOMWindowBase::namedItemGetter): Ditto.
(WebCore::JSDOMWindowBase::getOwnPropertySlot): Ditto.
(WebCore::JSDOMWindowBase::findJSEventListener): Ditto.
(WebCore::JSDOMWindowBase::findOrCreateJSEventListener): Ditto.
(WebCore::JSDOMWindowBase::findJSUnprotectedEventListener): Ditto.
(WebCore::JSDOMWindowBase::findOrCreateJSUnprotectedEventListener): Ditto.
(windowProtoFuncOpen): Use noValue.
(WebCore::toJSDOMWindow): Use asObject.
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::setTimeoutOrInterval): Use asString.
(WebCore::toDOMWindow): Use asObject.
* bindings/js/JSEventListener.cpp:
(WebCore::JSAbstractEventListener::handleEvent): Use noValue.
(WebCore::JSLazyEventListener::parseCode): Use asObject.
* bindings/js/JSHTMLCollectionCustom.cpp:
(WebCore::JSHTMLCollection::nameGetter): Use asObject.
* bindings/js/JSHTMLDocumentCustom.cpp:
(WebCore::JSHTMLDocument::nameGetter): Ditto.
* bindings/js/JSHTMLElementCustom.cpp:
(WebCore::JSHTMLElement::pushEventHandlerScope): Ditto.
* bindings/js/JSHTMLFormElementCustom.cpp:
(WebCore::JSHTMLFormElement::nameGetter): Ditto.
* bindings/js/JSHTMLFrameSetElementCustom.cpp:
(WebCore::JSHTMLFrameSetElement::nameGetter): Ditto.
* bindings/js/JSHTMLOptionElementConstructor.cpp:
(WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor): Ditto.
(WebCore::constructHTMLOptionElement): Ditto.
* bindings/js/JSHTMLOptionsCollectionCustom.cpp:
(WebCore::JSHTMLOptionsCollection::remove): Ditto.
* bindings/js/JSImageConstructor.cpp:
(WebCore::JSImageConstructor::JSImageConstructor): Ditto.
(WebCore::constructImage): Ditto.
* bindings/js/JSInspectedObjectWrapper.cpp:
(WebCore::JSInspectedObjectWrapper::wrap): Ditto.
* bindings/js/JSInspectorCallbackWrapper.cpp:
(WebCore::JSInspectorCallbackWrapper::wrap): Ditto.
* bindings/js/JSJavaScriptCallFrameCustom.cpp:
(WebCore::JSJavaScriptCallFrame::evaluate): Use noValue.
* bindings/js/JSMessageChannelConstructor.cpp:
(WebCore::JSMessageChannelConstructor::JSMessageChannelConstructor): Use asObject.
(WebCore::JSMessageChannelConstructor::construct): Ditto.
* bindings/js/JSMimeTypeArrayCustom.cpp:
(WebCore::JSMimeTypeArray::nameGetter): Ditto.
* bindings/js/JSNamedNodeMapCustom.cpp:
(WebCore::JSNamedNodeMap::nameGetter): Ditto.
* bindings/js/JSNamedNodesCollection.cpp:
(WebCore::JSNamedNodesCollection::lengthGetter): Ditto.
(WebCore::JSNamedNodesCollection::indexGetter): Ditto.
* bindings/js/JSNodeFilterCustom.cpp:
(WebCore::toNodeFilter): Ditto.
* bindings/js/JSNodeListCustom.cpp:
(WebCore::JSNodeList::nameGetter): Ditto.
* bindings/js/JSPluginArrayCustom.cpp:
(WebCore::JSPluginArray::nameGetter): Ditto.
* bindings/js/JSPluginCustom.cpp:
(WebCore::JSPlugin::nameGetter): Ditto.
* bindings/js/JSPluginElementFunctions.cpp:
(WebCore::runtimeObjectGetter): Ditto.
(WebCore::runtimeObjectPropertyGetter): Ditto.
* bindings/js/JSQuarantinedObjectWrapper.cpp:
(WebCore::JSQuarantinedObjectWrapper::asWrapper): Ditto.
(WebCore::JSQuarantinedObjectWrapper::getOwnPropertySlot): Ditto.
(WebCore::JSQuarantinedObjectWrapper::construct): Ditto.
* bindings/js/JSRGBColor.cpp:
(jsRGBColorRed): Ditto.
(jsRGBColorGreen): Ditto.
(jsRGBColorBlue): Ditto.
* bindings/js/JSSQLResultSetRowListCustom.cpp:
(WebCore::JSSQLResultSetRowList::item): Use noValue.
* bindings/js/JSStorageCustom.cpp:
(WebCore::JSStorage::nameGetter): Use asObject.
(WebCore::JSStorage::deleteProperty): Ditto.
(WebCore::JSStorage::customPut): Ditto.
* bindings/js/JSStyleSheetListCustom.cpp:
(WebCore::JSStyleSheetList::nameGetter): Ditto.
* bindings/js/JSXMLHttpRequestConstructor.cpp:
(WebCore::JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor): Ditto.
* bindings/js/JSXSLTProcessorCustom.cpp:
(WebCore::JSXSLTProcessor::importStylesheet): Ditto.
(WebCore::JSXSLTProcessor::transformToFragment): Ditto.
(WebCore::JSXSLTProcessor::transformToDocument): Ditto.
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::evaluate): Use noValue.
* bindings/objc/DOMInternal.mm:
(-[WebScriptObject _initializeScriptDOMNodeImp]): Ditto.
* bindings/objc/WebScriptObject.mm:
(-[WebScriptObject evaluateWebScript:]): Use JSValuePtr.
(-[WebScriptObject valueForKey:]): Ditto.
(-[WebScriptObject webScriptValueAtIndex:]): Ditto.
(+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):
Use asObject and asString.
* bindings/scripts/CodeGeneratorJS.pm: Use asObject.
* bridge/c/c_instance.h: Use JSValuePtr.
* bridge/c/c_runtime.cpp:
(JSC::Bindings::CField::setValueToInstance): Ditto.
* bridge/c/c_utility.cpp:
(JSC::Bindings::convertValueToNPVariant): Use asObject.
* bridge/jni/jni_instance.cpp:
(JavaInstance::booleanValue): Use JSValuePtr.
(JavaInstance::invokeMethod): Ditto. And noValue.
* bridge/jni/jni_jsobject.mm:
(JavaJSObject::getSlot): Ditto.
(JavaJSObject::convertValueToJObject): Ditto.
* bridge/jni/jni_runtime.cpp:
(JavaField::dispatchValueFromInstance): Ditto.
(JavaField::valueFromInstance): Ditto.
(JavaField::dispatchSetValueToInstance): Ditto.
(JavaField::setValueToInstance): Ditto.
(JavaArray::setValueAt): Ditto.
(JavaArray::valueAt): Ditto.
* bridge/jni/jni_runtime.h: Ditto.
* bridge/jni/jni_utility.cpp:
(JSC::Bindings::convertArrayInstanceToJavaArray): Take a JSArray*
instead of a JSValue*.
(JSC::Bindings::convertValueToJValue): Use asObject and asArray.
* bridge/objc/objc_class.h: Use JSValuePtr.
* bridge/objc/objc_instance.h: Ditto.
* bridge/objc/objc_runtime.h: Ditto.
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::callObjCFallbackObject): Use asObject.
* bridge/objc/objc_utility.h: Use JSValuePtr.
* bridge/objc/objc_utility.mm:
(JSC::Bindings::convertValueToObjcValue): Use JSValuePtr and asObject.
(JSC::Bindings::convertObjcValueToValue): Use jsUndefined() instead of 0.
* bridge/runtime.cpp:
(JSC::Bindings::Instance::getValueOfField): Use JSValuePtr.
(JSC::Bindings::Instance::setValueOfField): Ditto.
* bridge/runtime_array.cpp:
(JSC::RuntimeArray::lengthGetter): Use JSValuePtr and asObject.
(JSC::RuntimeArray::indexGetter): Ditto.
* bridge/runtime_array.h: Ditto.
* bridge/runtime_method.cpp:
(JSC::RuntimeMethod::lengthGetter): Ditto.
(JSC::callRuntimeMethod): Ditto.
* bridge/runtime_object.cpp:
(JSC::RuntimeObjectImp::fallbackObjectGetter): Ditto.
(JSC::RuntimeObjectImp::fieldGetter): Ditto.
(JSC::RuntimeObjectImp::methodGetter): Ditto.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::executeScript): Use noValue.
* page/Console.cpp:
(WebCore::Console::trace): Use asInternalFunction.
WebKit/mac:
2008-10-18 Darin Adler <darin@apple.com>
Reviewed by Oliver Hunt.
- next step of https://bugs.webkit.org/show_bug.cgi?id=21732
improve performance by eliminating JSValue as a base class for JSCell
Tweak a little more to get closer to where we can make JSValuePtr a class.
* WebView/WebScriptDebugDelegate.mm:
(-[WebScriptCallFrame _convertValueToObjcValue:]): Use JSValuePtr.
(-[WebScriptCallFrame exception]): Ditto.
(-[WebScriptCallFrame evaluateWebScript:]): Ditto. And noValue.
* WebView/WebScriptDebugger.mm:
(WebScriptDebugger::WebScriptDebugger): Use new DebuggerCallFrame
constructor that doesn't require explicitly passing an exception.
* WebView/WebView.mm:
(aeDescFromJSValue): Use JSValuePtr.
(-[WebView aeDescByEvaluatingJavaScriptFromString:]): Ditto.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@37705
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
inline JSC::JSValuePtr toJS(JSValueRef v)
{
- return reinterpret_cast<JSC::JSValuePtr>(const_cast<OpaqueJSValue*>(v));
+ return reinterpret_cast<JSC::JSValue*>(const_cast<OpaqueJSValue*>(v));
}
inline JSC::JSObject* toJS(JSObjectRef o)
2008-10-18 Darin Adler <darin@apple.com>
+ Reviewed by Oliver Hunt.
+
+ - next step of https://bugs.webkit.org/show_bug.cgi?id=21732
+ improve performance by eliminating JSValue as a base class for JSCell
+
+ Tweak a little more to get closer to where we can make JSValuePtr a class.
+
+ * API/APICast.h:
+ (toJS): Change back to JSValue* here, since we're converting the
+ pointer type.
+ * VM/CTI.cpp:
+ (JSC::CTI::unlinkCall): Call asPointer.
+ * VM/CTI.h: Cast to JSValue* here, since it's a pointer cast.
+ * kjs/DebuggerCallFrame.h:
+ (JSC::DebuggerCallFrame::DebuggerCallFrame): Call noValue.
+ * kjs/JSGlobalData.cpp:
+ (JSC::JSGlobalData::JSGlobalData): Call noValue.
+ * kjs/JSImmediate.cpp:
+ (JSC::JSImmediate::toObject): Remove unneeded const_cast.
+ * kjs/JSWrapperObject.h:
+ (JSC::JSWrapperObject::JSWrapperObject): Call noValue.
+
+2008-10-18 Darin Adler <darin@apple.com>
+
- fix non-all-in-one build
* kjs/completion.h:
// When the JSFunction is deleted the pointer embedded in the instruction stream will no longer be valid
// (and, if a new JSFunction happened to be constructed at the same location, we could get a false positive
// match). Reset the check so it no longer matches.
- reinterpret_cast<void**>(structureStubInfo->hotPathBegin)[-1] = JSImmediate::impossibleValue();
+ reinterpret_cast<void**>(structureStubInfo->hotPathBegin)[-1] = asPointer(JSImmediate::impossibleValue());
}
void CTI::linkCall(CodeBlock* callerCodeBlock, JSFunction* callee, CodeBlock* calleeCodeBlock, void* ctiCode, void* returnAddress, int callerArgCount)
#define ARG_setCallFrame(newCallFrame) (ARGS[CTI_ARGS_callFrame] = (newCallFrame))
-#define ARG_src1 static_cast<JSValuePtr>(ARGS[1])
-#define ARG_src2 static_cast<JSValuePtr>(ARGS[2])
-#define ARG_src3 static_cast<JSValuePtr>(ARGS[3])
-#define ARG_src4 static_cast<JSValuePtr>(ARGS[4])
-#define ARG_src5 static_cast<JSValuePtr>(ARGS[5])
+#define ARG_src1 static_cast<JSValue*>(ARGS[1])
+#define ARG_src2 static_cast<JSValue*>(ARGS[2])
+#define ARG_src3 static_cast<JSValue*>(ARGS[3])
+#define ARG_src4 static_cast<JSValue*>(ARGS[4])
+#define ARG_src5 static_cast<JSValue*>(ARGS[5])
#define ARG_id1 static_cast<Identifier*>(ARGS[1])
#define ARG_id2 static_cast<Identifier*>(ARGS[2])
#define ARG_id3 static_cast<Identifier*>(ARGS[3])
DebuggerCallFrame(CallFrame* callFrame)
: m_callFrame(callFrame)
- , m_exception(0)
+ , m_exception(noValue())
{
}
JSGlobalData::JSGlobalData(bool isShared)
: machine(new Machine)
- , exception(0)
+ , exception(noValue())
, arrayTable(new HashTable(JSC::arrayTable))
, dateTable(new HashTable(JSC::dateTable))
, mathTable(new HashTable(JSC::mathTable))
{
ASSERT(isImmediate(v));
if (isNumber(v))
- return constructNumberFromImmediateNumber(exec, const_cast<JSValuePtr>(v));
+ return constructNumberFromImmediateNumber(exec, v);
if (isBoolean(v))
- return constructBooleanFromImmediateBoolean(exec, const_cast<JSValuePtr>(v));
+ return constructBooleanFromImmediateBoolean(exec, v);
JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v->isNull());
exec->setException(exception);
inline JSWrapperObject::JSWrapperObject(PassRefPtr<StructureID> structure)
: JSObject(structure)
- , m_internalValue(0)
+ , m_internalValue(noValue())
{
}
2008-10-18 Darin Adler <darin@apple.com>
+ Reviewed by Oliver Hunt.
+
+ - next step of https://bugs.webkit.org/show_bug.cgi?id=21732
+ improve performance by eliminating JSValue as a base class for JSCell
+
+ Tweak a little more to get closer to where we can make JSValuePtr a class.
+
+ * JSObject.cpp:
+ (nativeCallFunction): Call asObject.
+
+ * JSUtils.cpp:
+ (KJSValueToJSObject): Use JSValuePtr and asObject.
+ (JSObjectKJSValue): Ditto.
+ (KJSValueToCFTypeInternal): Ditto.
+ (KJSValueToCFType): Ditto.
+ * JSUtils.h: Ditto.
+
+ * UserObjectImp.cpp:
+ (UserObjectImp::callAsFunction): Use JSValuePtr and asObject.
+ (UserObjectImp::userObjectGetter): Ditto.
+ (UserObjectImp::getOwnPropertySlot): Ditto.
+ (UserObjectImp::put): Ditto.
+ (UserObjectImp::toPrimitive): Ditto.
+ * UserObjectImp.h: Ditto.
+
+2008-10-18 Darin Adler <darin@apple.com>
+
Reviewed by Cameron Zwarich.
- next step on https://bugs.webkit.org/show_bug.cgi?id=21732
static JSValuePtr nativeCallFunction(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args)
{
- return static_cast<UserObjectImp*>(functionObject)->callAsFunction(exec, static_cast<JSObject*>(thisValue), args);
+ return static_cast<UserObjectImp*>(functionObject)->callAsFunction(exec, asObject(thisValue), args);
}
CallType JSUserObject::getCallData(CallData& callData)
CFTypeRef data;
};
-static CFTypeRef KJSValueToCFTypeInternal(JSValue *inValue, ExecState *exec, ObjectImpList* inImps);
+static CFTypeRef KJSValueToCFTypeInternal(JSValuePtr inValue, ExecState *exec, ObjectImpList* inImps);
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// KJSValueToJSObject
//--------------------------------------------------------------------------
-JSUserObject* KJSValueToJSObject(JSValue *inValue, ExecState *exec)
+JSUserObject* KJSValueToJSObject(JSValuePtr inValue, ExecState *exec)
{
JSUserObject* result = 0;
if (inValue->isObject(&UserObjectImp::info)) {
- UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(inValue);
+ UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(asObject(inValue));
result = userObjectImp->GetJSUserObject();
if (result)
result->Retain();
//--------------------------------------------------------------------------
// JSObjectKJSValue
//--------------------------------------------------------------------------
-JSValue *JSObjectKJSValue(JSUserObject* ptr)
+JSValuePtr JSObjectKJSValue(JSUserObject* ptr)
{
JSLock lock(true);
- JSValue *result = jsUndefined();
+ JSValuePtr result = jsUndefined();
if (ptr)
{
bool handled = false;
// KJSValueToCFTypeInternal
//--------------------------------------------------------------------------
// Caller is responsible for releasing the returned CFTypeRef
-CFTypeRef KJSValueToCFTypeInternal(JSValue *inValue, ExecState *exec, ObjectImpList* inImps)
+CFTypeRef KJSValueToCFTypeInternal(JSValuePtr inValue, ExecState *exec, ObjectImpList* inImps)
{
if (!inValue)
return 0;
if (inValue->isObject())
{
if (inValue->isObject(&UserObjectImp::info)) {
- UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(inValue);
+ UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(asObject(inValue));
JSUserObject* ptr = userObjectImp->GetJSUserObject();
if (ptr)
{
return 0;
}
-CFTypeRef KJSValueToCFType(JSValue *inValue, ExecState *exec)
+CFTypeRef KJSValueToCFType(JSValuePtr inValue, ExecState *exec)
{
return KJSValueToCFTypeInternal(inValue, exec, 0);
}
CFStringRef UStringToCFString(const UString& inUString);
Identifier CFStringToIdentifier(CFStringRef inCFString, ExecState*);
CFStringRef IdentifierToCFString(const Identifier& inIdentifier);
-JSUserObject *KJSValueToJSObject(JSValue *inValue, ExecState *exec);
-CFTypeRef KJSValueToCFType(JSValue *inValue, ExecState *exec);
-JSValue *JSObjectKJSValue(JSUserObject* ptr);
+JSUserObject *KJSValueToJSObject(JSValuePtr inValue, ExecState *exec);
+CFTypeRef KJSValueToCFType(JSValuePtr inValue, ExecState *exec);
+JSValuePtr JSObjectKJSValue(JSUserObject* ptr);
CFTypeRef GetCFNull(void);
inline CFTypeRef RetainCFType(CFTypeRef x) { if (x) x = CFRetain(x); return x; }
return fJSUserObject ? fJSUserObject->getCallData(callData) : CallTypeNone;
}
-JSValue *UserObjectImp::callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args)
+JSValuePtr UserObjectImp::callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args)
{
- JSValue *result = jsUndefined();
+ JSValuePtr result = jsUndefined();
JSUserObject* jsThisObj = KJSValueToJSObject(thisObj, exec);
if (jsThisObj) {
CFIndex argCount = args.size();
JSValuePtr UserObjectImp::userObjectGetter(ExecState*, const Identifier& propertyName, const PropertySlot& slot)
{
- UserObjectImp *thisObj = static_cast<UserObjectImp *>(slot.slotBase());
+ UserObjectImp *thisObj = static_cast<UserObjectImp *>(asObject(slot.slotBase()));
// getOwnPropertySlot should have guarded against a null fJSUserObject.
assert(thisObj->fJSUserObject);
CFStringRef cfPropName = IdentifierToCFString(propertyName);
JSUserObject *jsResult = thisObj->fJSUserObject->CopyProperty(cfPropName);
ReleaseCFType(cfPropName);
- JSValue *result = JSObjectKJSValue(jsResult);
+ JSValuePtr result = JSObjectKJSValue(jsResult);
jsResult->Release();
return result;
jsResult->Release();
return true;
} else {
- JSValue *kjsValue = toPrimitive(exec);
+ JSValuePtr kjsValue = toPrimitive(exec);
if (!kjsValue->isUndefinedOrNull()) {
JSObject *kjsObject = kjsValue->toObject(exec);
if (kjsObject->getPropertySlot(exec, propertyName, slot))
return JSObject::getOwnPropertySlot(exec, propertyName, slot);
}
-void UserObjectImp::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
+void UserObjectImp::put(ExecState *exec, const Identifier &propertyName, JSValuePtr value, int attr)
{
if (!fJSUserObject)
return;
return fJSUserObject;
}
-JSValue *UserObjectImp::toPrimitive(ExecState *exec, JSType) const
+JSValuePtr UserObjectImp::toPrimitive(ExecState *exec, JSType) const
{
- JSValue *result = jsUndefined();
+ JSValuePtr result = jsUndefined();
JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec);
CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0;
if (cfValue) {
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
- virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args);
+ virtual JSValuePtr callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args);
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
- virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
+ virtual void put(ExecState *exec, const Identifier &propertyName, JSValuePtr value, int attr = None);
JSValuePtr toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const;
virtual bool toBoolean(ExecState *exec) const;
+2008-10-18 Darin Adler <darin@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ - next step of https://bugs.webkit.org/show_bug.cgi?id=21732
+ improve performance by eliminating JSValue as a base class for JSCell
+
+ Tweak a little more to get closer to where we can make JSValuePtr a class.
+
+ * bindings/js/JSAudioConstructor.cpp:
+ (WebCore::JSAudioConstructor::JSAudioConstructor): Use asObject.
+ (WebCore::constructAudio): Ditto.
+ * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+ (WebCore::JSCSSStyleDeclaration::nameGetter): Ditto.
+
+ * bindings/js/JSCanvasRenderingContext2DCustom.cpp:
+ (WebCore::toHTMLCanvasStyle): Use asString and asObject.
+ (WebCore::JSCanvasRenderingContext2D::setFillColor): Ditto.
+ (WebCore::JSCanvasRenderingContext2D::setStrokeColor): Ditto.
+ (WebCore::JSCanvasRenderingContext2D::drawImage): Ditto.
+ (WebCore::JSCanvasRenderingContext2D::drawImageFromRect): Ditto.
+ (WebCore::JSCanvasRenderingContext2D::setShadow): Ditto.
+ (WebCore::JSCanvasRenderingContext2D::createPattern): Ditto.
+
+ * bindings/js/JSCustomSQLTransactionErrorCallback.cpp:
+ (WebCore::JSCustomSQLTransactionErrorCallback::handleEvent): Use JSValuePtr.
+
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::setDOMException): Use noValue.
+
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::getDOMPrototype): Use asObject.
+
+ * bindings/js/JSDOMWindowBase.cpp:
+ (WebCore::showModalDialog): Use noValue.
+ (jsDOMWindowBaseEvent): Use asObject.
+ (jsDOMWindowBaseImage): Ditto.
+ (jsDOMWindowBaseMessageChannel): Ditto.
+ (jsDOMWindowBaseOption): Ditto.
+ (jsDOMWindowBaseXMLHttpRequest): Ditto.
+ (jsDOMWindowBaseAudio): Ditto.
+ (jsDOMWindowBaseXSLTProcessor): Ditto.
+ (WebCore::JSDOMWindowBase::childFrameGetter): Ditto.
+ (WebCore::JSDOMWindowBase::indexGetter): Ditto.
+ (WebCore::JSDOMWindowBase::namedItemGetter): Ditto.
+ (WebCore::JSDOMWindowBase::getOwnPropertySlot): Ditto.
+ (WebCore::JSDOMWindowBase::findJSEventListener): Ditto.
+ (WebCore::JSDOMWindowBase::findOrCreateJSEventListener): Ditto.
+ (WebCore::JSDOMWindowBase::findJSUnprotectedEventListener): Ditto.
+ (WebCore::JSDOMWindowBase::findOrCreateJSUnprotectedEventListener): Ditto.
+ (windowProtoFuncOpen): Use noValue.
+ (WebCore::toJSDOMWindow): Use asObject.
+
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::setTimeoutOrInterval): Use asString.
+ (WebCore::toDOMWindow): Use asObject.
+
+ * bindings/js/JSEventListener.cpp:
+ (WebCore::JSAbstractEventListener::handleEvent): Use noValue.
+ (WebCore::JSLazyEventListener::parseCode): Use asObject.
+
+ * bindings/js/JSHTMLCollectionCustom.cpp:
+ (WebCore::JSHTMLCollection::nameGetter): Use asObject.
+ * bindings/js/JSHTMLDocumentCustom.cpp:
+ (WebCore::JSHTMLDocument::nameGetter): Ditto.
+ * bindings/js/JSHTMLElementCustom.cpp:
+ (WebCore::JSHTMLElement::pushEventHandlerScope): Ditto.
+ * bindings/js/JSHTMLFormElementCustom.cpp:
+ (WebCore::JSHTMLFormElement::nameGetter): Ditto.
+ * bindings/js/JSHTMLFrameSetElementCustom.cpp:
+ (WebCore::JSHTMLFrameSetElement::nameGetter): Ditto.
+ * bindings/js/JSHTMLOptionElementConstructor.cpp:
+ (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor): Ditto.
+ (WebCore::constructHTMLOptionElement): Ditto.
+ * bindings/js/JSHTMLOptionsCollectionCustom.cpp:
+ (WebCore::JSHTMLOptionsCollection::remove): Ditto.
+ * bindings/js/JSImageConstructor.cpp:
+ (WebCore::JSImageConstructor::JSImageConstructor): Ditto.
+ (WebCore::constructImage): Ditto.
+ * bindings/js/JSInspectedObjectWrapper.cpp:
+ (WebCore::JSInspectedObjectWrapper::wrap): Ditto.
+ * bindings/js/JSInspectorCallbackWrapper.cpp:
+ (WebCore::JSInspectorCallbackWrapper::wrap): Ditto.
+
+ * bindings/js/JSJavaScriptCallFrameCustom.cpp:
+ (WebCore::JSJavaScriptCallFrame::evaluate): Use noValue.
+
+ * bindings/js/JSMessageChannelConstructor.cpp:
+ (WebCore::JSMessageChannelConstructor::JSMessageChannelConstructor): Use asObject.
+ (WebCore::JSMessageChannelConstructor::construct): Ditto.
+ * bindings/js/JSMimeTypeArrayCustom.cpp:
+ (WebCore::JSMimeTypeArray::nameGetter): Ditto.
+ * bindings/js/JSNamedNodeMapCustom.cpp:
+ (WebCore::JSNamedNodeMap::nameGetter): Ditto.
+ * bindings/js/JSNamedNodesCollection.cpp:
+ (WebCore::JSNamedNodesCollection::lengthGetter): Ditto.
+ (WebCore::JSNamedNodesCollection::indexGetter): Ditto.
+ * bindings/js/JSNodeFilterCustom.cpp:
+ (WebCore::toNodeFilter): Ditto.
+ * bindings/js/JSNodeListCustom.cpp:
+ (WebCore::JSNodeList::nameGetter): Ditto.
+ * bindings/js/JSPluginArrayCustom.cpp:
+ (WebCore::JSPluginArray::nameGetter): Ditto.
+ * bindings/js/JSPluginCustom.cpp:
+ (WebCore::JSPlugin::nameGetter): Ditto.
+ * bindings/js/JSPluginElementFunctions.cpp:
+ (WebCore::runtimeObjectGetter): Ditto.
+ (WebCore::runtimeObjectPropertyGetter): Ditto.
+ * bindings/js/JSQuarantinedObjectWrapper.cpp:
+ (WebCore::JSQuarantinedObjectWrapper::asWrapper): Ditto.
+ (WebCore::JSQuarantinedObjectWrapper::getOwnPropertySlot): Ditto.
+ (WebCore::JSQuarantinedObjectWrapper::construct): Ditto.
+ * bindings/js/JSRGBColor.cpp:
+ (jsRGBColorRed): Ditto.
+ (jsRGBColorGreen): Ditto.
+ (jsRGBColorBlue): Ditto.
+
+ * bindings/js/JSSQLResultSetRowListCustom.cpp:
+ (WebCore::JSSQLResultSetRowList::item): Use noValue.
+
+ * bindings/js/JSStorageCustom.cpp:
+ (WebCore::JSStorage::nameGetter): Use asObject.
+ (WebCore::JSStorage::deleteProperty): Ditto.
+ (WebCore::JSStorage::customPut): Ditto.
+ * bindings/js/JSStyleSheetListCustom.cpp:
+ (WebCore::JSStyleSheetList::nameGetter): Ditto.
+ * bindings/js/JSXMLHttpRequestConstructor.cpp:
+ (WebCore::JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor): Ditto.
+ * bindings/js/JSXSLTProcessorCustom.cpp:
+ (WebCore::JSXSLTProcessor::importStylesheet): Ditto.
+ (WebCore::JSXSLTProcessor::transformToFragment): Ditto.
+ (WebCore::JSXSLTProcessor::transformToDocument): Ditto.
+
+ * bindings/js/ScriptController.cpp:
+ (WebCore::ScriptController::evaluate): Use noValue.
+ * bindings/objc/DOMInternal.mm:
+ (-[WebScriptObject _initializeScriptDOMNodeImp]): Ditto.
+
+ * bindings/objc/WebScriptObject.mm:
+ (-[WebScriptObject evaluateWebScript:]): Use JSValuePtr.
+ (-[WebScriptObject valueForKey:]): Ditto.
+ (-[WebScriptObject webScriptValueAtIndex:]): Ditto.
+ (+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):
+ Use asObject and asString.
+
+ * bindings/scripts/CodeGeneratorJS.pm: Use asObject.
+
+ * bridge/c/c_instance.h: Use JSValuePtr.
+ * bridge/c/c_runtime.cpp:
+ (JSC::Bindings::CField::setValueToInstance): Ditto.
+
+ * bridge/c/c_utility.cpp:
+ (JSC::Bindings::convertValueToNPVariant): Use asObject.
+
+ * bridge/jni/jni_instance.cpp:
+ (JavaInstance::booleanValue): Use JSValuePtr.
+ (JavaInstance::invokeMethod): Ditto. And noValue.
+ * bridge/jni/jni_jsobject.mm:
+ (JavaJSObject::getSlot): Ditto.
+ (JavaJSObject::convertValueToJObject): Ditto.
+ * bridge/jni/jni_runtime.cpp:
+ (JavaField::dispatchValueFromInstance): Ditto.
+ (JavaField::valueFromInstance): Ditto.
+ (JavaField::dispatchSetValueToInstance): Ditto.
+ (JavaField::setValueToInstance): Ditto.
+ (JavaArray::setValueAt): Ditto.
+ (JavaArray::valueAt): Ditto.
+ * bridge/jni/jni_runtime.h: Ditto.
+
+ * bridge/jni/jni_utility.cpp:
+ (JSC::Bindings::convertArrayInstanceToJavaArray): Take a JSArray*
+ instead of a JSValue*.
+ (JSC::Bindings::convertValueToJValue): Use asObject and asArray.
+
+ * bridge/objc/objc_class.h: Use JSValuePtr.
+ * bridge/objc/objc_instance.h: Ditto.
+ * bridge/objc/objc_runtime.h: Ditto.
+
+ * bridge/objc/objc_runtime.mm:
+ (JSC::Bindings::callObjCFallbackObject): Use asObject.
+
+ * bridge/objc/objc_utility.h: Use JSValuePtr.
+ * bridge/objc/objc_utility.mm:
+ (JSC::Bindings::convertValueToObjcValue): Use JSValuePtr and asObject.
+ (JSC::Bindings::convertObjcValueToValue): Use jsUndefined() instead of 0.
+
+ * bridge/runtime.cpp:
+ (JSC::Bindings::Instance::getValueOfField): Use JSValuePtr.
+ (JSC::Bindings::Instance::setValueOfField): Ditto.
+
+ * bridge/runtime_array.cpp:
+ (JSC::RuntimeArray::lengthGetter): Use JSValuePtr and asObject.
+ (JSC::RuntimeArray::indexGetter): Ditto.
+ * bridge/runtime_array.h: Ditto.
+ * bridge/runtime_method.cpp:
+ (JSC::RuntimeMethod::lengthGetter): Ditto.
+ (JSC::callRuntimeMethod): Ditto.
+ * bridge/runtime_object.cpp:
+ (JSC::RuntimeObjectImp::fallbackObjectGetter): Ditto.
+ (JSC::RuntimeObjectImp::fieldGetter): Ditto.
+ (JSC::RuntimeObjectImp::methodGetter): Ditto.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::executeScript): Use noValue.
+
+ * page/Console.cpp:
+ (WebCore::Console::trace): Use asInternalFunction.
+
2008-10-19 Dan Bernstein <mitz@apple.com>
Reviewed by Timothy Hatcher.
JSAudioConstructor::JSAudioConstructor(ExecState* exec, Document* document)
: DOMObject(JSAudioConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype()))
- , m_document(static_cast<JSDocument*>(toJS(exec, document)))
+ , m_document(static_cast<JSDocument*>(asObject(toJS(exec, document))))
{
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
}
audio->setSrc(args.at(exec, 0)->toString(exec));
audio->scheduleLoad();
}
- return static_cast<JSObject*>(toJS(exec, audio.release()));
+ return asObject(toJS(exec, audio.release()));
}
ConstructType JSAudioConstructor::getConstructData(ConstructData& constructData)
// but you should also be able to enumerate them.
JSValuePtr JSCSSStyleDeclaration::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSCSSStyleDeclaration* thisObj = static_cast<JSCSSStyleDeclaration*>(slot.slotBase());
+ JSCSSStyleDeclaration* thisObj = static_cast<JSCSSStyleDeclaration*>(asObject(slot.slotBase()));
// Set up pixelOrPos boolean to handle the fact that
// pixelTop returns "CSS Top" as number value in unit pixels
static PassRefPtr<CanvasStyle> toHTMLCanvasStyle(ExecState* exec, JSValuePtr value)
{
if (value->isString())
- return CanvasStyle::create(static_cast<JSString*>(value)->value());
+ return CanvasStyle::create(asString(value)->value());
if (!value->isObject())
return 0;
- JSObject* object = static_cast<JSObject*>(value);
+ JSObject* object = asObject(value);
if (object->inherits(&JSCanvasGradient::s_info))
return CanvasStyle::create(static_cast<JSCanvasGradient*>(object)->impl());
if (object->inherits(&JSCanvasPattern::s_info))
switch (args.size()) {
case 1:
if (args.at(exec, 0)->isString())
- context->setFillColor(static_cast<JSString*>(args.at(exec, 0))->value());
+ context->setFillColor(asString(args.at(exec, 0))->value());
else
context->setFillColor(args.at(exec, 0)->toFloat(exec));
break;
case 2:
if (args.at(exec, 0)->isString())
- context->setFillColor(static_cast<JSString*>(args.at(exec, 0))->value(), args.at(exec, 1)->toFloat(exec));
+ context->setFillColor(asString(args.at(exec, 0))->value(), args.at(exec, 1)->toFloat(exec));
else
context->setFillColor(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec));
break;
switch (args.size()) {
case 1:
if (args.at(exec, 0)->isString())
- context->setStrokeColor(static_cast<JSString*>(args.at(exec, 0))->value());
+ context->setStrokeColor(asString(args.at(exec, 0))->value());
else
context->setStrokeColor(args.at(exec, 0)->toFloat(exec));
break;
case 2:
if (args.at(exec, 0)->isString())
- context->setStrokeColor(static_cast<JSString*>(args.at(exec, 0))->value(), args.at(exec, 1)->toFloat(exec));
+ context->setStrokeColor(asString(args.at(exec, 0))->value(), args.at(exec, 1)->toFloat(exec));
else
context->setStrokeColor(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec));
break;
JSValuePtr value = args.at(exec, 0);
if (!value->isObject())
return throwError(exec, TypeError);
- JSObject* o = static_cast<JSObject*>(value);
+ JSObject* o = asObject(value);
ExceptionCode ec = 0;
if (o->inherits(&JSHTMLImageElement::s_info)) {
- HTMLImageElement* imgElt = static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args.at(exec, 0))->impl());
+ HTMLImageElement* imgElt = static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(o)->impl());
switch (args.size()) {
case 3:
context->drawImage(imgElt, args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec));
return throwError(exec, SyntaxError);
}
} else if (o->inherits(&JSHTMLCanvasElement::s_info)) {
- HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(args.at(exec, 0))->impl());
+ HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(o)->impl());
switch (args.size()) {
case 3:
context->drawImage(canvas, args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec));
}
} else {
setDOMException(exec, TYPE_MISMATCH_ERR);
- return 0;
}
return jsUndefined();
JSValuePtr value = args.at(exec, 0);
if (!value->isObject())
return throwError(exec, TypeError);
- JSObject* o = static_cast<JSObject*>(value);
+ JSObject* o = asObject(value);
if (!o->inherits(&JSHTMLImageElement::s_info))
return throwError(exec, TypeError);
- context->drawImageFromRect(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args.at(exec, 0))->impl()),
+ context->drawImageFromRect(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(o)->impl()),
args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec),
args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec),
args.at(exec, 5)->toFloat(exec), args.at(exec, 6)->toFloat(exec),
case 4:
if (args.at(exec, 3)->isString())
context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec),
- args.at(exec, 2)->toFloat(exec), static_cast<JSString*>(args.at(exec, 3))->value());
+ args.at(exec, 2)->toFloat(exec), asString(args.at(exec, 3))->value());
else
context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec),
args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec));
case 5:
if (args.at(exec, 3)->isString())
context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec),
- args.at(exec, 2)->toFloat(exec), static_cast<JSString*>(args.at(exec, 3))->value(),
+ args.at(exec, 2)->toFloat(exec), asString(args.at(exec, 3))->value(),
args.at(exec, 4)->toFloat(exec));
else
context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec),
JSValuePtr value = args.at(exec, 0);
if (!value->isObject())
return throwError(exec, TypeError);
- JSObject* o = static_cast<JSObject*>(value);
+ JSObject* o = asObject(value);
if (o->inherits(&JSHTMLImageElement::s_info)) {
ExceptionCode ec;
JSValuePtr pattern = toJS(exec,
- context->createPattern(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args.at(exec, 0))->impl()),
+ context->createPattern(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(o)->impl()),
valueToStringWithNullCheck(exec, args.at(exec, 1)), ec).get());
setDOMException(exec, ec);
return pattern;
if (o->inherits(&JSHTMLCanvasElement::s_info)) {
ExceptionCode ec;
JSValuePtr pattern = toJS(exec,
- context->createPattern(static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(args.at(exec, 0))->impl()),
+ context->createPattern(static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(o)->impl()),
valueToStringWithNullCheck(exec, args.at(exec, 1)), ec).get());
setDOMException(exec, ec);
return pattern;
}
setDOMException(exec, TYPE_MISMATCH_ERR);
- return 0;
+ return jsUndefined();
}
JSValuePtr JSCanvasRenderingContext2D::putImageData(ExecState* exec, const ArgList& args)
ArgList args;
args.append(toJS(exec, error));
- JSValue *result;
+ JSValuePtr result;
globalObject->startTimeoutCheck();
result = call(exec, function, callType, callData, m_callback, args);
globalObject->stopTimeoutCheck();
ExceptionCodeDescription description;
getExceptionCodeDescription(ec, description);
- JSValuePtr errorObject = 0;
+ JSValuePtr errorObject = noValue();
switch (description.type) {
case DOMExceptionType:
errorObject = toJS(exec, DOMCoreException::create(description));
}
template<class WrapperClass> inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec)
{
- return static_cast<JSC::JSObject*>(getDOMStructure<WrapperClass>(exec)->storedPrototype());
+ return static_cast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(exec)->storedPrototype()));
}
template<class ConstructorClass> inline JSC::JSObject* getDOMConstructor(JSC::ExecState* exec)
{
// Get the return value either just before clearing the dialog window's
// properties (in JSDOMWindowBase::clear), or when on return from runModal.
- JSValuePtr returnValue = 0;
+ JSValuePtr returnValue = noValue();
dialogWindow->setReturnValueSlot(&returnValue);
dialogFrame->page()->chrome()->runModal();
dialogWindow->setReturnValueSlot(0);
JSValuePtr jsDOMWindowBaseEvent(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- if (!static_cast<JSDOMWindowBase*>(slot.slotBase())->allowsAccessFrom(exec))
+ if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec))
return jsUndefined();
- if (!static_cast<JSDOMWindowBase*>(slot.slotBase())->currentEvent())
+ if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->currentEvent())
return jsUndefined();
- return toJS(exec, static_cast<JSDOMWindowBase*>(slot.slotBase())->currentEvent());
+ return toJS(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->currentEvent());
}
JSValuePtr jsDOMWindowBaseImage(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- if (!static_cast<JSDOMWindowBase*>(slot.slotBase())->allowsAccessFrom(exec))
+ if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec))
return jsUndefined();
- return getDOMConstructor<JSImageConstructor>(exec, static_cast<JSDOMWindowBase*>(slot.slotBase()));
+ return getDOMConstructor<JSImageConstructor>(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase())));
}
JSValuePtr jsDOMWindowBaseMessageChannel(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- if (!static_cast<JSDOMWindowBase*>(slot.slotBase())->allowsAccessFrom(exec))
+ if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec))
return jsUndefined();
- return getDOMConstructor<JSMessageChannelConstructor>(exec, static_cast<JSDOMWindowBase*>(slot.slotBase()));
+ return getDOMConstructor<JSMessageChannelConstructor>(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase())));
}
JSValuePtr jsDOMWindowBaseOption(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- if (!static_cast<JSDOMWindowBase*>(slot.slotBase())->allowsAccessFrom(exec))
+ if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec))
return jsUndefined();
- return getDOMConstructor<JSHTMLOptionElementConstructor>(exec, static_cast<JSDOMWindowBase*>(slot.slotBase()));
+ return getDOMConstructor<JSHTMLOptionElementConstructor>(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase())));
}
JSValuePtr jsDOMWindowBaseXMLHttpRequest(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- if (!static_cast<JSDOMWindowBase*>(slot.slotBase())->allowsAccessFrom(exec))
+ if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec))
return jsUndefined();
- return getDOMConstructor<JSXMLHttpRequestConstructor>(exec, static_cast<JSDOMWindowBase*>(slot.slotBase()));
+ return getDOMConstructor<JSXMLHttpRequestConstructor>(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase())));
}
JSValuePtr jsDOMWindowBaseAudio(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
#if ENABLE(VIDEO)
- if (!static_cast<JSDOMWindowBase*>(slot.slotBase())->allowsAccessFrom(exec))
+ if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec))
return jsUndefined();
if (!MediaPlayer::isAvailable())
return jsUndefined();
- return getDOMConstructor<JSAudioConstructor>(exec, static_cast<JSDOMWindowBase*>(slot.slotBase()));
+ return getDOMConstructor<JSAudioConstructor>(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase())));
#else
return jsUndefined();
#endif
JSValuePtr jsDOMWindowBaseXSLTProcessor(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
#if ENABLE(XSLT)
- if (!static_cast<JSDOMWindowBase*>(slot.slotBase())->allowsAccessFrom(exec))
+ if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec))
return jsUndefined();
return getDOMConstructor<JSXSLTProcessorConstructor>(exec);
#else
JSValuePtr JSDOMWindowBase::childFrameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- return toJS(exec, static_cast<JSDOMWindowBase*>(slot.slotBase())->impl()->frame()->tree()->child(AtomicString(propertyName))->domWindow());
+ return toJS(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->impl()->frame()->tree()->child(AtomicString(propertyName))->domWindow());
}
JSValuePtr JSDOMWindowBase::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- return toJS(exec, static_cast<JSDOMWindowBase*>(slot.slotBase())->impl()->frame()->tree()->child(slot.index())->domWindow());
+ return toJS(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->impl()->frame()->tree()->child(slot.index())->domWindow());
}
JSValuePtr JSDOMWindowBase::namedItemGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSDOMWindowBase* thisObj = static_cast<JSDOMWindowBase*>(slot.slotBase());
+ JSDOMWindowBase* thisObj = static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()));
Document* doc = thisObj->impl()->frame()->document();
ASSERT(thisObj->allowsAccessFrom(exec));
ASSERT(doc);
// precedence over the index and name getters.
JSValuePtr proto = prototype();
if (proto->isObject()) {
- if (static_cast<JSObject*>(proto)->getPropertySlot(exec, propertyName, slot)) {
+ if (asObject(proto)->getPropertySlot(exec, propertyName, slot)) {
if (!allowsAccessFrom(exec))
slot.setUndefined();
return true;
{
if (!val->isObject())
return 0;
- JSObject* object = static_cast<JSObject*>(val);
+ JSObject* object = asObject(val);
ListenersMap& listeners = attachedToEventTargetNode ? d()->jsEventListenersAttachedToEventTargetNodes : d()->jsEventListeners;
return listeners.get(object);
}
return 0;
// The JSEventListener constructor adds it to our jsEventListeners map.
- return JSEventListener::create(static_cast<JSObject*>(val), static_cast<JSDOMWindow*>(this), attachedToEventTargetNode).get();
+ return JSEventListener::create(asObject(val), static_cast<JSDOMWindow*>(this), attachedToEventTargetNode).get();
}
JSUnprotectedEventListener* JSDOMWindowBase::findJSUnprotectedEventListener(ExecState* exec, JSValuePtr val, bool attachedToEventTargetNode)
return 0;
UnprotectedListenersMap& listeners = attachedToEventTargetNode ? d()->jsUnprotectedEventListenersAttachedToEventTargetNodes : d()->jsUnprotectedEventListeners;
- return listeners.get(static_cast<JSObject*>(val));
+ return listeners.get(asObject(val));
}
PassRefPtr<JSUnprotectedEventListener> JSDOMWindowBase::findOrCreateJSUnprotectedEventListener(ExecState* exec, JSValuePtr val, bool attachedToEventTargetNode)
return 0;
// The JSUnprotectedEventListener constructor adds it to our jsUnprotectedEventListeners map.
- return JSUnprotectedEventListener::create(static_cast<JSObject*>(val), static_cast<JSDOMWindow*>(this), attachedToEventTargetNode).get();
+ return JSUnprotectedEventListener::create(asObject(val), static_cast<JSDOMWindow*>(this), attachedToEventTargetNode).get();
}
void JSDOMWindowBase::clearHelperObjectProperties()
windowFeatures.height = windowRect.height();
windowFeatures.width = windowRect.width();
- frame = createWindow(exec, frame, urlString, frameName, windowFeatures, 0);
+ frame = createWindow(exec, frame, urlString, frameName, windowFeatures, noValue());
if (!frame)
return jsUndefined();
{
if (!value->isObject())
return 0;
- const ClassInfo* classInfo = static_cast<JSObject*>(value)->classInfo();
+ const ClassInfo* classInfo = asObject(value)->classInfo();
if (classInfo == &JSDOMWindow::s_info)
- return static_cast<JSDOMWindow*>(value);
+ return static_cast<JSDOMWindow*>(asObject(value));
if (classInfo == &JSDOMWindowShell::s_info)
- return static_cast<JSDOMWindowShell*>(value)->window();
+ return static_cast<JSDOMWindowShell*>(asObject(value))->window();
return 0;
}
JSValuePtr v = args.at(exec, 0);
int delay = args.at(exec, 1)->toInt32(exec);
if (v->isString())
- return jsNumber(exec, window->installTimeout(static_cast<JSString*>(v)->value(), delay, timeout));
+ return jsNumber(exec, window->installTimeout(asString(v)->value(), delay, timeout));
CallData callData;
if (v->getCallData(callData) == CallTypeNone)
return jsUndefined();
return jsUndefined();
}
-DOMWindow* toDOMWindow(JSValuePtr val)
+DOMWindow* toDOMWindow(JSValuePtr value)
{
- if (val->isObject(&JSDOMWindow::s_info))
- return static_cast<JSDOMWindow*>(val)->impl();
- if (val->isObject(&JSDOMWindowShell::s_info))
- return static_cast<JSDOMWindowShell*>(val)->impl();
+ if (!value->isObject())
+ return 0;
+ JSObject* object = asObject(value);
+ if (object->inherits(&JSDOMWindow::s_info))
+ return static_cast<JSDOMWindow*>(object)->impl();
+ if (object->inherits(&JSDOMWindowShell::s_info))
+ return static_cast<JSDOMWindowShell*>(object)->impl();
return 0;
}
CallData callData;
CallType callType = handleEventFunction->getCallData(callData);
if (callType == CallTypeNone) {
- handleEventFunction = 0;
+ handleEventFunction = noValue();
callType = listener->getCallData(callData);
}
JSValuePtr thisObj = toJS(exec, m_originalNode);
if (thisObj->isObject()) {
- static_cast<JSEventTargetNode*>(thisObj)->pushEventHandlerScope(exec, scope);
+ static_cast<JSEventTargetNode*>(asObject(thisObj))->pushEventHandlerScope(exec, scope);
listenerAsFunction->setScope(scope);
}
}
JSValuePtr JSHTMLCollection::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(slot.slotBase());
+ JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(asObject(slot.slotBase()));
return getNamedItems(exec, thisObj->impl(), propertyName);
}
JSValuePtr JSHTMLDocument::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSHTMLDocument* thisObj = static_cast<JSHTMLDocument*>(slot.slotBase());
+ JSHTMLDocument* thisObj = static_cast<JSHTMLDocument*>(asObject(slot.slotBase()));
HTMLDocument* document = static_cast<HTMLDocument*>(thisObj->impl());
String name = propertyName;
HTMLElement* element = impl();
// The document is put on first, fall back to searching it only after the element and form.
- scope.push(static_cast<JSObject*>(toJS(exec, element->ownerDocument())));
+ scope.push(asObject(toJS(exec, element->ownerDocument())));
// The form is next, searched before the document, but after the element itself.
if (HTMLFormElement* form = element->form())
- scope.push(static_cast<JSObject*>(toJS(exec, form)));
+ scope.push(asObject(toJS(exec, form)));
// The element is on top, searched first.
- scope.push(static_cast<JSObject*>(toJS(exec, element)));
+ scope.push(asObject(toJS(exec, element)));
}
} // namespace WebCore
JSValuePtr JSHTMLFormElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- HTMLFormElement* form = static_cast<HTMLFormElement*>(static_cast<JSHTMLElement*>(slot.slotBase())->impl());
+ HTMLFormElement* form = static_cast<HTMLFormElement*>(static_cast<JSHTMLElement*>(asObject(slot.slotBase()))->impl());
Vector<RefPtr<Node> > namedItems;
form->getNamedElements(propertyName, namedItems);
JSValuePtr JSHTMLFrameSetElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(slot.slotBase());
+ JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(asObject(slot.slotBase()));
HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl());
Node* frame = element->children()->namedItem(propertyName);
JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor(ExecState* exec, Document* document)
: DOMObject(JSHTMLOptionElementConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype()))
- , m_document(static_cast<JSDocument*>(toJS(exec, document)))
+ , m_document(static_cast<JSDocument*>(asObject(toJS(exec, document))))
{
putDirect(exec->propertyNames().length, jsNumber(exec, 4), ReadOnly|DontDelete|DontEnum);
}
return 0;
}
- return static_cast<JSObject*>(toJS(exec, element.release()));
+ return asObject(toJS(exec, element.release()));
}
ConstructType JSHTMLOptionElementConstructor::getConstructData(ConstructData& constructData)
JSValuePtr JSHTMLOptionsCollection::remove(ExecState* exec, const ArgList& args)
{
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
- JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(toJS(exec, imp->base()));
+ JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(asObject(toJS(exec, imp->base())));
return base->remove(exec, args);
}
JSImageConstructor::JSImageConstructor(ExecState* exec, Document* document)
: DOMObject(JSImageConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype()))
- , m_document(static_cast<JSDocument*>(toJS(exec, document)))
+ , m_document(static_cast<JSDocument*>(asObject(toJS(exec, document))))
{
}
image->setWidth(width);
if (heightSet)
image->setHeight(height);
- return static_cast<JSObject*>(toJS(exec, image.release()));
+ return asObject(toJS(exec, image.release()));
}
ConstructType JSImageConstructor::getConstructData(ConstructData& constructData)
if (!unwrappedValue->isObject())
return unwrappedValue;
- JSObject* unwrappedObject = static_cast<JSObject*>(unwrappedValue);
+ JSObject* unwrappedObject = asObject(unwrappedValue);
if (unwrappedObject->inherits(&JSInspectedObjectWrapper::s_info))
return unwrappedObject;
if (prototype->isNull())
return new (unwrappedExec) JSInspectedObjectWrapper(unwrappedExec, unwrappedObject, JSQuarantinedObjectWrapper::createStructureID(jsNull()));
- return new (unwrappedExec) JSInspectedObjectWrapper(unwrappedExec, unwrappedObject, JSQuarantinedObjectWrapper::createStructureID(static_cast<JSObject*>(wrap(unwrappedExec, prototype))));
+ return new (unwrappedExec) JSInspectedObjectWrapper(unwrappedExec, unwrappedObject, JSQuarantinedObjectWrapper::createStructureID(asObject(wrap(unwrappedExec, prototype))));
}
JSInspectedObjectWrapper::JSInspectedObjectWrapper(ExecState* unwrappedExec, JSObject* unwrappedObject, PassRefPtr<StructureID> structureID)
if (!unwrappedValue->isObject())
return unwrappedValue;
- JSObject* unwrappedObject = static_cast<JSObject*>(unwrappedValue);
+ JSObject* unwrappedObject = asObject(unwrappedValue);
if (unwrappedObject->inherits(&JSInspectorCallbackWrapper::s_info))
return unwrappedObject;
if (prototype->isNull())
return new (unwrappedExec) JSInspectorCallbackWrapper(unwrappedExec, unwrappedObject, unwrappedExec->globalData().nullProtoStructureID);
- return new (unwrappedExec) JSInspectorCallbackWrapper(unwrappedExec, unwrappedObject, static_cast<JSObject*>(wrap(unwrappedExec, prototype))->inheritorID());
+ return new (unwrappedExec) JSInspectorCallbackWrapper(unwrappedExec, unwrappedObject, asObject(wrap(unwrappedExec, prototype))->inheritorID());
}
JSInspectorCallbackWrapper::JSInspectorCallbackWrapper(ExecState* unwrappedExec, JSObject* unwrappedObject, PassRefPtr<StructureID> structureID)
JSValuePtr JSJavaScriptCallFrame::evaluate(ExecState* exec, const ArgList& args)
{
- JSValuePtr exception = 0;
+ JSValuePtr exception = noValue();
JSValuePtr result = impl()->evaluate(args.at(exec, 0)->toString(exec), exception);
if (exception)
JSMessageChannelConstructor::JSMessageChannelConstructor(ExecState* exec, Document* document)
: DOMObject(JSMessageChannelConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype()))
- , m_document(static_cast<JSDocument*>(toJS(exec, document)))
+ , m_document(static_cast<JSDocument*>(asObject(toJS(exec, document))))
{
putDirect(exec->propertyNames().prototype, JSMessageChannelPrototype::self(exec), None);
}
JSObject* JSMessageChannelConstructor::construct(ExecState* exec, JSObject* constructor, const ArgList&)
{
- return static_cast<JSObject*>(toJS(exec, MessageChannel::create(static_cast<JSMessageChannelConstructor*>(constructor)->document())));
+ return asObject(toJS(exec, MessageChannel::create(static_cast<JSMessageChannelConstructor*>(constructor)->document())));
}
void JSMessageChannelConstructor::mark()
JSValuePtr JSMimeTypeArray::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSMimeTypeArray* thisObj = static_cast<JSMimeTypeArray*>(slot.slotBase());
+ JSMimeTypeArray* thisObj = static_cast<JSMimeTypeArray*>(asObject(slot.slotBase()));
return toJS(exec, thisObj->impl()->nameGetter(propertyName));
}
JSValuePtr JSNamedNodeMap::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSNamedNodeMap* thisObj = static_cast<JSNamedNodeMap*>(slot.slotBase());
+ JSNamedNodeMap* thisObj = static_cast<JSNamedNodeMap*>(asObject(slot.slotBase()));
return toJS(exec, thisObj->impl()->getNamedItem(propertyName));
}
JSValuePtr JSNamedNodesCollection::lengthGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSNamedNodesCollection* thisObj = static_cast<JSNamedNodesCollection*>(slot.slotBase());
+ JSNamedNodesCollection* thisObj = static_cast<JSNamedNodesCollection*>(asObject(slot.slotBase()));
return jsNumber(exec, thisObj->m_nodes->size());
}
JSValuePtr JSNamedNodesCollection::indexGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSNamedNodesCollection *thisObj = static_cast<JSNamedNodesCollection*>(slot.slotBase());
+ JSNamedNodesCollection *thisObj = static_cast<JSNamedNodesCollection*>(asObject(slot.slotBase()));
return toJS(exec, (*thisObj->m_nodes)[slot.index()].get());
}
PassRefPtr<NodeFilter> toNodeFilter(JSValuePtr value)
{
if (value->isObject(&JSNodeFilter::s_info))
- return static_cast<JSNodeFilter*>(value)->impl();
+ return static_cast<JSNodeFilter*>(asObject(value))->impl();
return NodeFilter::create(JSNodeFilterCondition::create(value));
}
JSValuePtr JSNodeList::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSNodeList* thisObj = static_cast<JSNodeList*>(slot.slotBase());
+ JSNodeList* thisObj = static_cast<JSNodeList*>(asObject(slot.slotBase()));
return toJS(exec, thisObj->impl()->itemWithName(propertyName));
}
JSValuePtr JSPluginArray::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSPluginArray* thisObj = static_cast<JSPluginArray*>(slot.slotBase());
+ JSPluginArray* thisObj = static_cast<JSPluginArray*>(asObject(slot.slotBase()));
return toJS(exec, thisObj->impl()->nameGetter(propertyName));
}
JSValuePtr JSPlugin::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSPlugin* thisObj = static_cast<JSPlugin*>(slot.slotBase());
+ JSPlugin* thisObj = static_cast<JSPlugin*>(asObject(slot.slotBase()));
return toJS(exec, thisObj->impl()->nameGetter(propertyName));
}
JSValuePtr runtimeObjectGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(slot.slotBase());
+ JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(asObject(slot.slotBase()));
HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl());
RuntimeObjectImp* runtimeObject = getRuntimeObject(exec, element);
return runtimeObject ? runtimeObject : jsUndefined();
JSValuePtr runtimeObjectPropertyGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(slot.slotBase());
+ JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(asObject(slot.slotBase()));
HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl());
RuntimeObjectImp* runtimeObject = getRuntimeObject(exec, element);
if (!runtimeObject)
if (!value->isObject())
return 0;
- JSObject* object = static_cast<JSObject*>(value);
+ JSObject* object = asObject(value);
if (!object->inherits(&JSQuarantinedObjectWrapper::s_info))
return 0;
bool result = m_unwrappedObject->getOwnPropertySlot(unwrappedExecState(), identifier, unwrappedSlot);
if (result) {
JSValuePtr unwrappedValue = unwrappedSlot.getValue(unwrappedExecState(), identifier);
- slot.setCustom(static_cast<JSObject*>(wrapOutgoingValue(unwrappedExecState(), unwrappedValue)), cachedValueGetter);
+ slot.setCustom(asObject(wrapOutgoingValue(unwrappedExecState(), unwrappedValue)), cachedValueGetter);
}
transferExceptionToExecState(exec);
bool result = m_unwrappedObject->getOwnPropertySlot(unwrappedExecState(), identifier, unwrappedSlot);
if (result) {
JSValuePtr unwrappedValue = unwrappedSlot.getValue(unwrappedExecState(), identifier);
- slot.setCustom(static_cast<JSObject*>(wrapOutgoingValue(unwrappedExecState(), unwrappedValue)), cachedValueGetter);
+ slot.setCustom(asObject(wrapOutgoingValue(unwrappedExecState(), unwrappedValue)), cachedValueGetter);
}
transferExceptionToExecState(exec);
JSValuePtr resultValue = wrapper->wrapOutgoingValue(wrapper->unwrappedExecState(), unwrappedResult);
ASSERT(resultValue->isObject());
- JSObject* result = static_cast<JSObject*>(resultValue);
+ JSObject* result = asObject(resultValue);
wrapper->transferExceptionToExecState(exec);
JSValuePtr jsRGBColorRed(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- return toJS(exec, CSSPrimitiveValue::create((static_cast<JSRGBColor*>(slot.slotBase())->impl() >> 16) & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
+ return toJS(exec, CSSPrimitiveValue::create((static_cast<JSRGBColor*>(asObject(slot.slotBase()))->impl() >> 16) & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
}
JSValuePtr jsRGBColorGreen(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- return toJS(exec, CSSPrimitiveValue::create((static_cast<JSRGBColor*>(slot.slotBase())->impl() >> 8) & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
+ return toJS(exec, CSSPrimitiveValue::create((static_cast<JSRGBColor*>(asObject(slot.slotBase()))->impl() >> 8) & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
}
JSValuePtr jsRGBColorBlue(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- return toJS(exec, CSSPrimitiveValue::create(static_cast<JSRGBColor*>(slot.slotBase())->impl() & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
+ return toJS(exec, CSSPrimitiveValue::create(static_cast<JSRGBColor*>(asObject(slot.slotBase()))->impl() & 0xFF, CSSPrimitiveValue::CSS_NUMBER));
}
unsigned valuesIndex = index * numColumns;
for (unsigned i = 0; i < numColumns; i++) {
const SQLValue& value = m_impl->values()[valuesIndex + i];
- JSValuePtr jsValue = 0;
+ JSValuePtr jsValue = noValue();
switch (value.type()) {
case SQLValue::StringValue:
JSValuePtr JSStorage::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSStorage* thisObj = static_cast<JSStorage*>(slot.slotBase());
+ JSStorage* thisObj = static_cast<JSStorage*>(asObject(slot.slotBase()));
return jsStringOrNull(exec, thisObj->impl()->getItem(propertyName));
}
return false;
JSValuePtr prototype = this->prototype();
- if (prototype->isObject() && static_cast<JSObject*>(prototype)->hasProperty(exec, propertyName))
+ if (prototype->isObject() && asObject(prototype)->hasProperty(exec, propertyName))
return false;
m_impl->removeItem(propertyName);
return false;
JSValuePtr prototype = this->prototype();
- if (prototype->isObject() && static_cast<JSObject*>(prototype)->hasProperty(exec, propertyName))
+ if (prototype->isObject() && asObject(prototype)->hasProperty(exec, propertyName))
return false;
String stringValue = valueToStringWithNullCheck(exec, value);
JSValuePtr JSStyleSheetList::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- JSStyleSheetList* thisObj = static_cast<JSStyleSheetList*>(slot.slotBase());
+ JSStyleSheetList* thisObj = static_cast<JSStyleSheetList*>(asObject(slot.slotBase()));
HTMLStyleElement* element = thisObj->impl()->getNamedItem(propertyName);
ASSERT(element);
return toJS(exec, element->sheet());
JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor(ExecState* exec, Document* document)
: DOMObject(JSXMLHttpRequestConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype()))
- , m_document(static_cast<JSDocument*>(toJS(exec, document)))
+ , m_document(static_cast<JSDocument*>(asObject(toJS(exec, document))))
{
putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec), None);
}
{
JSValuePtr nodeVal = args.at(exec, 0);
if (nodeVal->isObject(&JSNode::s_info)) {
- JSNode* node = static_cast<JSNode*>(nodeVal);
+ JSNode* node = static_cast<JSNode*>(asObject(nodeVal));
impl()->importStylesheet(node->impl());
return jsUndefined();
}
JSValuePtr nodeVal = args.at(exec, 0);
JSValuePtr docVal = args.at(exec, 1);
if (nodeVal->isObject(&JSNode::s_info) && docVal->isObject(&JSDocument::s_info)) {
- WebCore::Node* node = static_cast<JSNode*>(nodeVal)->impl();
- Document* doc = static_cast<Document*>(static_cast<JSDocument*>(docVal)->impl());
+ WebCore::Node* node = static_cast<JSNode*>(asObject(nodeVal))->impl();
+ Document* doc = static_cast<Document*>(static_cast<JSDocument*>(asObject(docVal))->impl());
return toJS(exec, impl()->transformToFragment(node, doc).get());
}
// Throw exception?
{
JSValuePtr nodeVal = args.at(exec, 0);
if (nodeVal->isObject(&JSNode::s_info)) {
- JSNode* node = static_cast<JSNode*>(nodeVal);
+ JSNode* node = static_cast<JSNode*>(asObject(nodeVal));
RefPtr<Document> resultDocument = impl()->transformToDocument(node->impl());
if (resultDocument)
return toJS(exec, resultDocument.get());
m_frame->domWindow()->console()->reportException(exec, comp.value());
m_sourceURL = savedSourceURL;
- return 0;
+ return noValue();
}
void ScriptController::clearWindowShell()
JSC::ExecState *exec = frame->script()->globalObject()->globalExec();
// Get (or create) a cached JS object for the DOM node.
- JSC::JSObject *scriptImp = static_cast<JSC::JSObject*>(WebCore::toJS(exec, nodeImpl));
+ JSC::JSObject *scriptImp = asObject(WebCore::toJS(exec, nodeImpl));
JSC::Bindings::RootObject* rootObject = frame->script()->bindingRootObject();
ExecState* exec = [self _rootObject]->globalObject()->globalExec();
ASSERT(!exec->hadException());
- JSValue *result;
+ JSValuePtr result;
JSLock lock(false);
[self _rootObject]->globalObject()->startTimeoutCheck();
// leaving the lock permanently held
JSLock lock(false);
- JSValue *result = [self _imp]->get(exec, Identifier(exec, String(key)));
+ JSValuePtr result = [self _imp]->get(exec, Identifier(exec, String(key)));
if (exec->hadException()) {
addExceptionToConsole(exec);
ASSERT(!exec->hadException());
JSLock lock(false);
- JSValue *result = [self _imp]->get(exec, index);
+ JSValuePtr result = [self _imp]->get(exec, index);
if (exec->hadException()) {
addExceptionToConsole(exec);
+ (id)_convertValueToObjcValue:(JSValuePtr)value originRootObject:(RootObject*)originRootObject rootObject:(RootObject*)rootObject
{
if (value->isObject()) {
- JSObject* object = static_cast<JSObject*>(value);
+ JSObject* object = asObject(value);
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock(false);
if (object->classInfo() != &RuntimeObjectImp::s_info) {
JSValuePtr runtimeObject = object->get(exec, Identifier(exec, "__apple_runtime_object"));
if (runtimeObject && runtimeObject->isObject())
- object = static_cast<RuntimeObjectImp*>(runtimeObject);
+ object = asObject(runtimeObject);
}
if (object->classInfo() == &RuntimeObjectImp::s_info) {
}
if (value->isString()) {
- const UString& u = static_cast<JSString*>(value)->value();
+ const UString& u = asString(value)->value();
return [NSString stringWithCharacters:u.data() length:u.size()];
}
if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection") {
push(@getOwnPropertySlotImpl, " ${namespaceMaybe}JSValuePtr proto = prototype();\n");
- push(@getOwnPropertySlotImpl, " if (proto->isObject() && static_cast<${namespaceMaybe}JSObject*>(proto)->hasProperty(exec, propertyName))\n");
+ push(@getOwnPropertySlotImpl, " if (proto->isObject() && static_cast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n");
push(@getOwnPropertySlotImpl, " return false;\n\n");
}
if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} &&
!$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"} &&
!$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurityOnGet"}) {
- push(@implContent, " if (!static_cast<$className*>(slot.slotBase())->allowsAccessFrom(exec))\n");
+ push(@implContent, " if (!static_cast<$className*>(asObject(slot.slotBase()))->allowsAccessFrom(exec))\n");
push(@implContent, " return jsUndefined();\n");
}
if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"CustomGetter"}) {
- push(@implContent, " return static_cast<$className*>(slot.slotBase())->$implGetterFunctionName(exec);\n");
+ push(@implContent, " return static_cast<$className*>(asObject(slot.slotBase()))->$implGetterFunctionName(exec);\n");
} elsif ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) {
$implIncludes{"JSDOMBinding.h"} = 1;
- push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(slot.slotBase())->impl());\n");
- push(@implContent, " return checkNodeSecurity(exec, imp->$implGetterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "static_cast<$className*>(slot.slotBase())") . " : jsUndefined();\n");
+ push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n");
+ push(@implContent, " return checkNodeSecurity(exec, imp->$implGetterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "static_cast<$className*>(asObject(slot.slotBase()))") . " : jsUndefined();\n");
} elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) {
$implIncludes{"Document.h"} = 1;
$implIncludes{"JSDOMBinding.h"} = 1;
- push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(slot.slotBase())->impl());\n");
- push(@implContent, " return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "static_cast<$className*>(slot.slotBase())") . " : jsUndefined();\n");
+ push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n");
+ push(@implContent, " return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "static_cast<$className*>(asObject(slot.slotBase()))") . " : jsUndefined();\n");
} elsif ($type eq "EventListener") {
$implIncludes{"JSEventListener.h"} = 1;
$implIncludes{"EventListener.h"} = 1;
} else {
$listenerType = "JSUnprotectedEventListener";
}
- push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(slot.slotBase())->impl());\n");
+ push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n");
push(@implContent, " if (${listenerType}* listener = static_cast<${listenerType}*>(imp->$implGetterFunctionName())) {\n");
push(@implContent, " if (JSObject* listenerObj = listener->listenerObj())\n");
push(@implContent, " return listenerObj;\n");
push(@implContent, " return JS" . $constructorType . "::getConstructor(exec);\n");
} elsif (!@{$attribute->getterExceptions}) {
if ($podType) {
- push(@implContent, " $podType imp(*static_cast<$className*>(slot.slotBase())->impl());\n");
+ push(@implContent, " $podType imp(*static_cast<$className*>(asObject(slot.slotBase()))->impl());\n");
if ($podType eq "float") { # Special case for JSSVGNumber
- push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp", "static_cast<$className*>(slot.slotBase())") . ";\n");
+ push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n");
} else {
- push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName()", "static_cast<$className*>(slot.slotBase())") . ";\n");
+ push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName()", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n");
}
} else {
- push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(slot.slotBase())->impl());\n");
- my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "static_cast<$className*>(slot.slotBase())");
+ push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n");
+ my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "static_cast<$className*>(asObject(slot.slotBase()))");
if ($codeGenerator->IsSVGAnimatedType($type)) {
push(@implContent, " RefPtr<$type> obj = $jsType;\n");
push(@implContent, " return toJS(exec, obj.get(), imp);\n");
push(@implContent, " ExceptionCode ec = 0;\n");
if ($podType) {
- push(@implContent, " $podType imp(*static_cast<$className*>(slot.slotBase())->impl());\n");
- push(@implContent, " JSC::JSValuePtr result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName(ec)", "static_cast<$className*>(slot.slotBase())") . ";\n");
+ push(@implContent, " $podType imp(*static_cast<$className*>(asObject(slot.slotBase()))->impl());\n");
+ push(@implContent, " JSC::JSValuePtr result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName(ec)", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n");
} else {
- push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(slot.slotBase())->impl());\n");
- push(@implContent, " JSC::JSValuePtr result = " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName(ec)", "static_cast<$className*>(slot.slotBase())") . ";\n");
+ push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n");
+ push(@implContent, " JSC::JSValuePtr result = " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName(ec)", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n");
}
push(@implContent, " setDOMException(exec, ec);\n");
push(@implContent, "JSValuePtr ${constructorFunctionName}(ExecState* exec, const Identifier&, const PropertySlot& slot)\n");
push(@implContent, "{\n");
- push(@implContent, " return static_cast<$className*>(slot.slotBase())->getConstructor(exec);\n");
+ push(@implContent, " return static_cast<$className*>(asObject(slot.slotBase()))->getConstructor(exec);\n");
push(@implContent, "}\n");
}
}
} else {
push(@implContent, " if (!thisValue->isObject(&${className}::s_info))\n");
push(@implContent, " return throwError(exec, TypeError);\n");
- push(@implContent, " $className* castedThisObj = static_cast<$className*>(thisValue);\n");
+ push(@implContent, " $className* castedThisObj = static_cast<$className*>(asObject(thisValue));\n");
}
if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} &&
}
if ($dataNode->extendedAttributes->{"HasIndexGetter"}) {
- push(@implContent, "\nJSValue* ${className}::indexGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)\n");
+ push(@implContent, "\nJSValuePtr ${className}::indexGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)\n");
push(@implContent, "{\n");
- push(@implContent, " ${className}* thisObj = static_cast<$className*>(slot.slotBase());\n");
+ push(@implContent, " ${className}* thisObj = static_cast<$className*>(asObject(slot.slotBase()));\n");
if (IndexGetterReturnsStrings($implClassName)) {
$implIncludes{"KURL.h"} = 1;
push(@implContent, " return jsStringOrNull(exec, thisObj->impl()->item(slot.index()));\n");
if ((!$hasParent or $dataNode->extendedAttributes->{"GenerateNativeConverter"}) and !$dataNode->extendedAttributes->{"CustomNativeConverter"}) {
if ($podType) {
- push(@implContent, "$podType to${interfaceName}(JSC::JSValuePtr val)\n");
+ push(@implContent, "$podType to${interfaceName}(JSC::JSValuePtr value)\n");
} else {
- push(@implContent, "$implClassName* to${interfaceName}(JSC::JSValuePtr val)\n");
+ push(@implContent, "$implClassName* to${interfaceName}(JSC::JSValuePtr value)\n");
}
push(@implContent, "{\n");
- push(@implContent, " return val->isObject(&${className}::s_info) ? " . ($podType ? "($podType) *" : "") . "static_cast<$className*>(val)->impl() : ");
+ push(@implContent, " return value->isObject(&${className}::s_info) ? " . ($podType ? "($podType) *" : "") . "static_cast<$className*>(asObject(value))->impl() : ");
if ($podType and $podType ne "float") {
push(@implContent, "$podType();\n}\n");
} else {
$implContent .= << "EOF";
static JSObject* construct(ExecState* exec, JSObject*, const ArgList&)
{
- return static_cast<JSObject*>(toJS(exec, ${interfaceName}::create()));
+ return asObject(toJS(exec, ${interfaceName}::create()));
}
virtual ConstructType getConstructData(ConstructData& constructData)
{
virtual JSValuePtr valueOf(ExecState*) const;
virtual JSValuePtr defaultValue(ExecState*, PreferredPrimitiveType) const;
- virtual JSValue *invokeMethod (ExecState *exec, const MethodList &method, const ArgList &args);
+ virtual JSValuePtr invokeMethod(ExecState*, const MethodList&, const ArgList&);
virtual bool supportsInvokeDefaultMethod() const;
- virtual JSValue *invokeDefaultMethod (ExecState *exec, const ArgList &args);
+ virtual JSValuePtr invokeDefaultMethod(ExecState*, const ArgList&);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
JSValuePtr stringValue(ExecState*) const;
return jsUndefined();
}
-void CField::setValueToInstance(ExecState *exec, const Instance *inst, JSValue *aValue) const
+void CField::setValueToInstance(ExecState *exec, const Instance *inst, JSValuePtr aValue) const
{
const CInstance* instance = static_cast<const CInstance*>(inst);
NPObject* obj = instance->getObject();
} else if (value->isNull()) {
NULL_TO_NPVARIANT(*result);
} else if (value->isObject()) {
- JSObject* object = static_cast<JSObject*>(value);
+ JSObject* object = asObject(value);
if (object->classInfo() == &RuntimeObjectImp::s_info) {
- RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(value);
+ RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(object);
CInstance* instance = static_cast<CInstance*>(imp->getInternalInstance());
if (instance) {
NPObject* obj = instance->getObject();
return jsNumber(exec, doubleValue);
}
-JSValue *JavaInstance::booleanValue() const
+JSValuePtr JavaInstance::booleanValue() const
{
jboolean booleanValue = callJNIMethod<jboolean>(_instance->_instance, "booleanValue", "()Z");
return jsBoolean(booleanValue);
}
-JSValue *JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const ArgList &args)
+JSValuePtr JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const ArgList &args)
{
int i, count = args.size();
jvalue *jArgs;
- JSValue *resultValue;
+ JSValuePtr resultValue;
Method *method = 0;
size_t numMethods = methodList.size();
for (i = 0; i < count; i++) {
JavaParameter* aParameter = jMethod->parameterAt(i);
- jArgs[i] = convertValueToJValue (exec, args.at(exec, i), aParameter->getJNIType(), aParameter->type());
+ jArgs[i] = convertValueToJValue(exec, args.at(exec, i), aParameter->getJNIType(), aParameter->type());
JS_LOG("arg[%d] = %s\n", i, args.at(exec, i)->toString(exec).ascii());
}
bool handled = false;
if (rootObject->nativeHandle()) {
jobject obj = _instance->_instance;
- JSValue *exceptionDescription = NULL;
+ JSValuePtr exceptionDescription = noValue();
const char *callingURL = 0; // FIXME, need to propagate calling URL to Java
handled = dispatchJNICall(exec, rootObject->nativeHandle(), obj, jMethod->isStatic(), jMethod->JNIReturnType(), jMethod->methodID(obj), jArgs, result, callingURL, exceptionDescription);
if (exceptionDescription) {
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock(false);
- JSValue *result = _imp->get (exec, (unsigned)index);
+ JSValuePtr result = _imp->get(exec, index);
return convertValueToJObject(result);
}
return nativeHandle;
}
-jobject JavaJSObject::convertValueToJObject (JSValue *value) const
+jobject JavaJSObject::convertValueToJObject(JSValuePtr value) const
{
JSLock lock(false);
jlong nativeHandle;
if (value->isObject()) {
- JSObject *imp = static_cast<JSObject*>(value);
+ JSObject* imp = asObject(value);
// We either have a wrapper around a Java instance or a JavaScript
// object. If we have a wrapper around a Java instance, return that
// instance, otherwise create a new Java JavaJSObject with the JSObject*
// as it's nativeHandle.
if (imp->classInfo() && strcmp(imp->classInfo()->className, "RuntimeObject") == 0) {
- RuntimeObjectImp *runtimeImp = static_cast<RuntimeObjectImp*>(value);
+ RuntimeObjectImp* runtimeImp = static_cast<RuntimeObjectImp*>(imp);
JavaInstance *runtimeInstance = static_cast<JavaInstance *>(runtimeImp->getInternalInstance());
if (!runtimeInstance)
return 0;
{
RootObject* rootObject = instance->rootObject();
if (rootObject && rootObject->nativeHandle()) {
- JSValue *exceptionDescription = NULL;
+ JSValuePtr exceptionDescription = noValue();
jvalue args[1];
args[0].l = jinstance;
return result;
}
-JSValue *JavaField::valueFromInstance(ExecState *exec, const Instance *i) const
+JSValuePtr JavaField::valueFromInstance(ExecState* exec, const Instance* i) const
{
const JavaInstance *instance = static_cast<const JavaInstance *>(i);
- JSValue *jsresult = jsUndefined();
+ JSValuePtr jsresult = jsUndefined();
switch (_JNIType) {
case array_type:
{
RootObject* rootObject = instance->rootObject();
if (rootObject && rootObject->nativeHandle()) {
- JSValue *exceptionDescription = NULL;
+ JSValuePtr exceptionDescription = noValue();
jvalue args[2];
jvalue result;
}
}
-void JavaField::setValueToInstance(ExecState *exec, const Instance *i, JSValue *aValue) const
+void JavaField::setValueToInstance(ExecState* exec, const Instance* i, JSValuePtr aValue) const
{
const JavaInstance *instance = static_cast<const JavaInstance *>(i);
jvalue javaValue = convertValueToJValue (exec, aValue, _JNIType, type());
return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0;
}
-void JavaArray::setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const
+void JavaArray::setValueAt(ExecState* exec, unsigned index, JSValuePtr aValue) const
{
JNIEnv *env = getJNIEnv();
char *javaClassName = 0;
}
-JSValue *JavaArray::valueAt(ExecState *exec, unsigned int index) const
+JSValuePtr JavaArray::valueAt(ExecState* exec, unsigned index) const
{
JNIEnv *env = getJNIEnv();
JNIType arrayType = JNITypeFromPrimitiveType(_type[1]);
public:
JavaField (JNIEnv *env, jobject aField);
- virtual JSValue *valueFromInstance(ExecState *exec, const Instance *instance) const;
- virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue *aValue) const;
+ virtual JSValuePtr valueFromInstance(ExecState *exec, const Instance *instance) const;
+ virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValuePtr aValue) const;
virtual const char *name() const { return _name.UTF8String(); }
virtual RuntimeType type() const { return _type.UTF8String(); }
RootObject* rootObject() const;
- virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const;
- virtual JSValue *valueAt(ExecState *exec, unsigned int index) const;
+ virtual void setValueAt(ExecState *exec, unsigned int index, JSValuePtr aValue) const;
+ virtual JSValuePtr valueAt(ExecState *exec, unsigned int index) const;
virtual unsigned int getLength() const;
jobject javaArray() const { return _array->_instance; }
return result;
}
-static jobject convertArrayInstanceToJavaArray(ExecState *exec, JSValue *value, const char *javaClassName)
+static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray, const char* javaClassName)
{
-
JNIEnv *env = getJNIEnv();
// As JS Arrays can contain a mixture of objects, assume we can convert to
// the requested Java Array type requested, unless the array type is some object array
// other than a string.
- JSArray *jsArray = static_cast<JSArray *>(value);
unsigned length = jsArray->length();
jobjectArray jarray = 0;
}
-jvalue convertValueToJValue (ExecState *exec, JSValue *value, JNIType _JNIType, const char *javaClassName)
+jvalue convertValueToJValue(ExecState* exec, JSValuePtr value, JNIType _JNIType, const char* javaClassName)
{
JSLock lock(false);
// First see if we have a Java instance.
if (value->isObject()){
- JSObject *objectImp = static_cast<JSObject*>(value);
+ JSObject* objectImp = asObject(value);
if (objectImp->classInfo() == &RuntimeObjectImp::s_info) {
- RuntimeObjectImp *imp = static_cast<RuntimeObjectImp *>(value);
+ RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(objectImp);
JavaInstance *instance = static_cast<JavaInstance*>(imp->getInternalInstance());
if (instance)
result.l = instance->javaInstance();
}
else if (objectImp->classInfo() == &RuntimeArray::s_info) {
// Input is a JavaScript Array that was originally created from a Java Array
- RuntimeArray *imp = static_cast<RuntimeArray *>(value);
+ RuntimeArray* imp = static_cast<RuntimeArray*>(objectImp);
JavaArray *array = static_cast<JavaArray*>(imp->getConcreteArray());
result.l = array->javaArray();
}
else if (objectImp->classInfo() == &JSArray::info) {
// Input is a Javascript Array. We need to create it to a Java Array.
- result.l = convertArrayInstanceToJavaArray(exec, value, javaClassName);
+ result.l = convertArrayInstanceToJavaArray(exec, asArray(value), javaClassName);
}
}
virtual MethodList methodsNamed(const Identifier&, Instance *instance) const;
virtual Field *fieldNamed(const Identifier&, Instance *instance) const;
- virtual JSValue *fallbackObject(ExecState *exec, Instance *instance, const Identifier &propertyName);
+ virtual JSValuePtr fallbackObject(ExecState *exec, Instance *instance, const Identifier &propertyName);
ClassStructPtr isa() { return _isa; }
virtual JSValuePtr valueOf(ExecState*) const;
virtual JSValuePtr defaultValue(ExecState*, PreferredPrimitiveType) const;
- virtual JSValue *invokeMethod(ExecState *exec, const MethodList &method, const ArgList &args);
+ virtual JSValuePtr invokeMethod(ExecState*, const MethodList&, const ArgList&);
virtual bool supportsInvokeDefaultMethod() const;
- virtual JSValue *invokeDefaultMethod(ExecState *exec, const ArgList &args);
+ virtual JSValuePtr invokeDefaultMethod(ExecState*, const ArgList&);
virtual bool supportsSetValueOfUndefinedField();
- virtual void setValueOfUndefinedField(ExecState *exec, const Identifier &property, JSValue *aValue);
+ virtual void setValueOfUndefinedField(ExecState*, const Identifier&, JSValuePtr);
virtual JSValuePtr getValueOfUndefinedField(ExecState*, const Identifier& property) const;
ObjcField(IvarStructPtr);
ObjcField(CFStringRef name);
- virtual JSValue *valueFromInstance(ExecState *exec, const Instance *instance) const;
- virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue *aValue) const;
+ virtual JSValuePtr valueFromInstance(ExecState*, const Instance*) const;
+ virtual void setValueToInstance(ExecState*, const Instance*, JSValuePtr) const;
virtual const char *name() const;
public:
ObjcArray(ObjectStructPtr, PassRefPtr<RootObject>);
- virtual void setValueAt(ExecState *exec, unsigned int index, JSValue *aValue) const;
- virtual JSValue *valueAt(ExecState *exec, unsigned int index) const;
+ virtual void setValueAt(ExecState *exec, unsigned int index, JSValuePtr aValue) const;
+ virtual JSValuePtr valueAt(ExecState *exec, unsigned int index) const;
virtual unsigned int getLength() const;
ObjectStructPtr getObjcArray() const { return _array.get(); }
- static JSValue *convertObjcArrayToArray(ExecState *exec, ObjectStructPtr anObject);
+ static JSValuePtr convertObjcArrayToArray(ExecState *exec, ObjectStructPtr anObject);
private:
RetainPtr<ObjectStructPtr> _array;
JSValuePtr result = jsUndefined();
- RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(thisValue);
+ RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(asObject(thisValue));
Instance* instance = imp->getInternalInstance();
if (!instance)
class RootObject;
-ObjcValue convertValueToObjcValue(ExecState *exec, JSValue *value, ObjcValueType type);
+ObjcValue convertValueToObjcValue(ExecState*, JSValuePtr, ObjcValueType);
JSValuePtr convertNSStringToString(ExecState* exec, NSString *nsstring);
-JSValue *convertObjcValueToValue(ExecState *exec, void *buffer, ObjcValueType type, RootObject*);
+JSValuePtr convertObjcValueToValue(ExecState*, void* buffer, ObjcValueType, RootObject*);
ObjcValueType objcValueTypeForType(const char *type);
bool convertJSMethodNameToObjc(const char *JSName, char *buffer, size_t bufferSize);
[], other exception
*/
-ObjcValue convertValueToObjcValue(ExecState *exec, JSValue *value, ObjcValueType type)
+ObjcValue convertValueToObjcValue(ExecState* exec, JSValuePtr value, ObjcValueType type)
{
ObjcValue result;
double d = 0;
RootObject* originRootObject = findRootObject(originGlobalObject);
JSGlobalObject* globalObject = 0;
- if (value->isObject() && static_cast<JSObject*>(value)->isGlobalObject())
- globalObject = static_cast<JSGlobalObject*>(value);
+ if (value->isObject() && asObject(value)->isGlobalObject())
+ globalObject = static_cast<JSGlobalObject*>(asObject(value));
if (!globalObject)
globalObject = originGlobalObject;
ASSERT(false);
}
- return 0;
+ return jsUndefined();
}
ObjcValueType objcValueTypeForType(const char *type)
virtualEnd();
}
-JSValue *Instance::getValueOfField(ExecState *exec, const Field *aField) const
+JSValuePtr Instance::getValueOfField(ExecState* exec, const Field* aField) const
{
return aField->valueFromInstance(exec, this);
}
-void Instance::setValueOfField(ExecState *exec, const Field *aField, JSValue *aValue) const
+void Instance::setValueOfField(ExecState* exec, const Field* aField, JSValuePtr aValue) const
{
aField->setValueToInstance(exec, this, aValue);
}
{
}
-JSValue *RuntimeArray::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
+JSValuePtr RuntimeArray::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- RuntimeArray *thisObj = static_cast<RuntimeArray *>(slot.slotBase());
+ RuntimeArray* thisObj = static_cast<RuntimeArray*>(asObject(slot.slotBase()));
return jsNumber(exec, thisObj->getLength());
}
-JSValue *RuntimeArray::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
+JSValuePtr RuntimeArray::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- RuntimeArray *thisObj = static_cast<RuntimeArray *>(slot.slotBase());
+ RuntimeArray* thisObj = static_cast<RuntimeArray*>(asObject(slot.slotBase()));
return thisObj->getConcreteArray()->valueAt(exec, slot.index());
}
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
- virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, PutPropertySlot&);
- virtual void put(ExecState *exec, unsigned propertyName, JSValue *value);
+ virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&);
+ virtual void put(ExecState*, unsigned propertyName, JSValuePtr);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
{
}
-JSValue *RuntimeMethod::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
+JSValuePtr RuntimeMethod::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
- RuntimeMethod *thisObj = static_cast<RuntimeMethod *>(slot.slotBase());
+ RuntimeMethod* thisObj = static_cast<RuntimeMethod*>(asObject(slot.slotBase()));
// Ick! There may be more than one method with this name. Arbitrarily
// just pick the first method. The fundamental problem here is that
RuntimeObjectImp* imp;
if (thisValue->isObject(&RuntimeObjectImp::s_info)) {
- imp = static_cast<RuntimeObjectImp*>(thisValue);
+ imp = static_cast<RuntimeObjectImp*>(asObject(thisValue));
} else {
// If thisObj is the DOM object for a plugin, get the corresponding
// runtime object from the DOM object.
JSValuePtr value = thisValue->get(exec, Identifier(exec, "__apple_runtime_object"));
if (value->isObject(&RuntimeObjectImp::s_info))
- imp = static_cast<RuntimeObjectImp*>(value);
+ imp = static_cast<RuntimeObjectImp*>(asObject(value));
else
return throwError(exec, TypeError);
}
JSValuePtr RuntimeObjectImp::fallbackObjectGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- RuntimeObjectImp *thisObj = static_cast<RuntimeObjectImp *>(slot.slotBase());
+ RuntimeObjectImp* thisObj = static_cast<RuntimeObjectImp*>(asObject(slot.slotBase()));
RefPtr<Instance> instance = thisObj->instance;
if (!instance)
JSValuePtr RuntimeObjectImp::fieldGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- RuntimeObjectImp *thisObj = static_cast<RuntimeObjectImp *>(slot.slotBase());
+ RuntimeObjectImp* thisObj = static_cast<RuntimeObjectImp*>(asObject(slot.slotBase()));
RefPtr<Instance> instance = thisObj->instance;
if (!instance)
Class *aClass = instance->getClass();
Field* aField = aClass->fieldNamed(propertyName, instance.get());
- JSValue *result = instance->getValueOfField(exec, aField);
+ JSValuePtr result = instance->getValueOfField(exec, aField);
instance->end();
JSValuePtr RuntimeObjectImp::methodGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
- RuntimeObjectImp *thisObj = static_cast<RuntimeObjectImp *>(slot.slotBase());
+ RuntimeObjectImp* thisObj = static_cast<RuntimeObjectImp*>(asObject(slot.slotBase()));
RefPtr<Instance> instance = thisObj->instance;
if (!instance)
JSValuePtr FrameLoader::executeScript(const String& url, int baseLine, const String& script)
{
if (!m_frame->script()->isEnabled() || m_frame->script()->isPaused())
- return 0;
+ return noValue();
bool wasRunningScript = m_isRunningScript;
m_isRunningScript = true;
ArgList args;
while (!func->isNull()) {
args.append(func);
- func = exec->machine()->retrieveCaller(exec, static_cast<InternalFunction*>(func));
+ func = exec->machine()->retrieveCaller(exec, asInternalFunction(func));
}
page->inspectorController()->addMessageToConsole(JSMessageSource, TraceMessageLevel, exec, args, 0, String());
+2008-10-18 Darin Adler <darin@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ - next step of https://bugs.webkit.org/show_bug.cgi?id=21732
+ improve performance by eliminating JSValue as a base class for JSCell
+
+ Tweak a little more to get closer to where we can make JSValuePtr a class.
+
+ * WebView/WebScriptDebugDelegate.mm:
+ (-[WebScriptCallFrame _convertValueToObjcValue:]): Use JSValuePtr.
+ (-[WebScriptCallFrame exception]): Ditto.
+ (-[WebScriptCallFrame evaluateWebScript:]): Ditto. And noValue.
+ * WebView/WebScriptDebugger.mm:
+ (WebScriptDebugger::WebScriptDebugger): Use new DebuggerCallFrame
+ constructor that doesn't require explicitly passing an exception.
+ * WebView/WebView.mm:
+ (aeDescFromJSValue): Use JSValuePtr.
+ (-[WebView aeDescByEvaluatingJavaScriptFromString:]): Ditto.
+
2008-10-18 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
@interface WebScriptCallFrame (WebScriptDebugDelegateInternal)
-- (id)_convertValueToObjcValue:(JSValue *)value;
+- (id)_convertValueToObjcValue:(JSValuePtr)value;
@end
_private->debuggerCallFrame = 0;
}
-- (id)_convertValueToObjcValue:(JSValue *)value
+- (id)_convertValueToObjcValue:(JSValuePtr)value
{
if (!value)
return nil;
if (!_private->debuggerCallFrame)
return nil;
- JSValue* exception = _private->debuggerCallFrame->exception();
+ JSValuePtr exception = _private->debuggerCallFrame->exception();
return exception ? [self _convertValueToObjcValue:exception] : nil;
}
JSLock lock(false);
- JSValue* exception = 0;
- JSValue* result = _private->debuggerCallFrame->evaluate(String(script), exception);
+ JSValuePtr exception = noValue();
+ JSValuePtr result = _private->debuggerCallFrame->evaluate(String(script), exception);
if (exception)
return [self _convertValueToObjcValue:exception];
return result ? [self _convertValueToObjcValue:result] : nil;
: m_callingDelegate(false)
{
attach(globalObject);
- DebuggerCallFrame globalCallFrame(globalObject->globalExec(), 0);
- callEvent(globalCallFrame, 0, -1);
+ callEvent(globalObject->globalExec(), 0, -1);
}
// callbacks - relay to delegate
return coreFrame->shouldClose();
}
-static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue* jsValue)
+static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValuePtr jsValue)
{
NSAppleEventDescriptor* aeDesc = 0;
if (jsValue->isBoolean())
return aeDesc;
}
}
- JSValue* primitive = object->toPrimitive(exec);
+ JSValuePtr primitive = object->toPrimitive(exec);
if (exec->hadException()) {
exec->clearException();
return [NSAppleEventDescriptor nullDescriptor];
return nil;
if (!coreFrame->document())
return nil;
- JSValue* result = coreFrame->loader()->executeScript(script, true);
+ JSValuePtr result = coreFrame->loader()->executeScript(script, true);
if (!result) // FIXME: pass errors
return 0;
JSLock lock(false);