From dcc8cf2e65d1aa555cce12431a16547e66b469ee Mon Sep 17 00:00:00 2001 From: Steve Block Date: Tue, 27 Apr 2010 16:31:00 +0100 Subject: Merge webkit.org at r58033 : Initial merge by git Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1 --- WebCore/bridge/c/c_instance.cpp | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'WebCore/bridge/c/c_instance.cpp') diff --git a/WebCore/bridge/c/c_instance.cpp b/WebCore/bridge/c/c_instance.cpp index 1b05259..7dbc1d9 100644 --- a/WebCore/bridge/c/c_instance.cpp +++ b/WebCore/bridge/c/c_instance.cpp @@ -29,15 +29,17 @@ #include "c_instance.h" +#include "CRuntimeObject.h" +#include "IdentifierRep.h" #include "c_class.h" #include "c_runtime.h" #include "c_utility.h" -#include "IdentifierRep.h" #include "npruntime_impl.h" +#include "runtime_method.h" #include "runtime_root.h" +#include #include #include -#include #include #include #include @@ -89,6 +91,11 @@ CInstance::~CInstance() _NPN_ReleaseObject(_object); } +RuntimeObject* CInstance::newRuntimeObject(ExecState* exec) +{ + return new (exec) CRuntimeObject(exec, this); +} + Class *CInstance::getClass() const { if (!_class) @@ -101,8 +108,33 @@ bool CInstance::supportsInvokeDefaultMethod() const return _object->_class->invokeDefault; } -JSValue CInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const ArgList& args) +class CRuntimeMethod : public RuntimeMethod { +public: + CRuntimeMethod(ExecState* exec, const Identifier& name, Bindings::MethodList& list) + : RuntimeMethod(exec, name, list) + { + } + + virtual const ClassInfo* classInfo() const { return &s_info; } + + static const ClassInfo s_info; +}; + +const ClassInfo CRuntimeMethod::s_info = { "CRuntimeMethod", &RuntimeMethod::s_info, 0, 0 }; + +JSValue CInstance::getMethod(ExecState* exec, const Identifier& propertyName) +{ + MethodList methodList = getClass()->methodsNamed(propertyName, this); + return new (exec) CRuntimeMethod(exec, propertyName, methodList); +} + +JSValue CInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod, const ArgList& args) { + if (!asObject(runtimeMethod)->inherits(&CRuntimeMethod::s_info)) + return throwError(exec, TypeError, "Attempt to invoke non-plug-in method on plug-in object."); + + const MethodList& methodList = *runtimeMethod->methods(); + // Overloading methods are not allowed by NPObjects. Should only be one // name match for a particular method. ASSERT(methodList.size() == 1); @@ -271,7 +303,7 @@ void CInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArray) IdentifierRep* identifier = static_cast(identifiers[i]); if (identifier->isString()) - nameArray.add(identifierFromNPIdentifier(identifier->string())); + nameArray.add(identifierFromNPIdentifier(exec, identifier->string())); else nameArray.add(Identifier::from(exec, identifier->number())); } -- cgit v1.1