diff options
author | Steve Block <steveblock@google.com> | 2010-04-27 16:31:00 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-05-11 14:42:12 +0100 |
commit | dcc8cf2e65d1aa555cce12431a16547e66b469ee (patch) | |
tree | 92a8d65cd5383bca9749f5327fb5e440563926e6 /WebCore/bridge/c/c_instance.cpp | |
parent | ccac38a6b48843126402088a309597e682f40fe6 (diff) | |
download | external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2 |
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebCore/bridge/c/c_instance.cpp')
-rw-r--r-- | WebCore/bridge/c/c_instance.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
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 <interpreter/CallFrame.h> #include <runtime/ArgList.h> #include <runtime/Error.h> -#include <interpreter/CallFrame.h> #include <runtime/JSLock.h> #include <runtime/JSNumberCell.h> #include <runtime/PropertyNameArray.h> @@ -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<IdentifierRep*>(identifiers[i]); if (identifier->isString()) - nameArray.add(identifierFromNPIdentifier(identifier->string())); + nameArray.add(identifierFromNPIdentifier(exec, identifier->string())); else nameArray.add(Identifier::from(exec, identifier->number())); } |