andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
laszlo.1.gombos@nokia.com | 4818396 | 2011-01-28 05:37:44 +0000 | [diff] [blame] | 26 | #include "config.h" |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 27 | #include "NPJSObject.h" |
| 28 | |
aestes@apple.com | 022b378 | 2012-05-16 03:55:58 +0000 | [diff] [blame] | 29 | #if ENABLE(NETSCAPE_PLUGIN_API) |
| 30 | |
andersca@apple.com | 21fcac3 | 2010-08-02 18:28:07 +0000 | [diff] [blame] | 31 | #include "JSNPObject.h" |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 32 | #include "NPRuntimeObjectMap.h" |
| 33 | #include "NPRuntimeUtilities.h" |
andersca@apple.com | 5b2497c | 2010-07-28 21:30:11 +0000 | [diff] [blame] | 34 | #include <JavaScriptCore/JSLock.h> |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 35 | #include <JavaScriptCore/JSObject.h> |
ggaren@apple.com | 7746b2e | 2011-10-02 00:54:56 +0000 | [diff] [blame] | 36 | #include <JavaScriptCore/StrongInlines.h> |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 37 | #include <WebCore/Frame.h> |
| 38 | #include <WebCore/IdentifierRep.h> |
weinig@apple.com | 7bf9683 | 2010-08-16 23:00:34 +0000 | [diff] [blame] | 39 | #include <wtf/text/WTFString.h> |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 40 | |
| 41 | using namespace JSC; |
| 42 | using namespace WebCore; |
| 43 | |
| 44 | namespace WebKit { |
| 45 | |
oliver@apple.com | 8d85705 | 2011-02-15 23:54:06 +0000 | [diff] [blame] | 46 | NPJSObject* NPJSObject::create(JSGlobalData& globalData, NPRuntimeObjectMap* objectMap, JSObject* jsObject) |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 47 | { |
andersca@apple.com | 21fcac3 | 2010-08-02 18:28:07 +0000 | [diff] [blame] | 48 | // We should never have a JSNPObject inside an NPJSObject. |
| 49 | ASSERT(!jsObject->inherits(&JSNPObject::s_info)); |
| 50 | |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 51 | NPJSObject* npJSObject = toNPJSObject(createNPObject(0, npClass())); |
oliver@apple.com | 8d85705 | 2011-02-15 23:54:06 +0000 | [diff] [blame] | 52 | npJSObject->initialize(globalData, objectMap, jsObject); |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 53 | |
| 54 | return npJSObject; |
| 55 | } |
| 56 | |
| 57 | NPJSObject::NPJSObject() |
| 58 | : m_objectMap(0) |
| 59 | { |
| 60 | } |
| 61 | |
| 62 | NPJSObject::~NPJSObject() |
| 63 | { |
| 64 | m_objectMap->npJSObjectDestroyed(this); |
| 65 | } |
| 66 | |
| 67 | bool NPJSObject::isNPJSObject(NPObject* npObject) |
| 68 | { |
| 69 | return npObject->_class == npClass(); |
| 70 | } |
| 71 | |
oliver@apple.com | 8d85705 | 2011-02-15 23:54:06 +0000 | [diff] [blame] | 72 | void NPJSObject::initialize(JSGlobalData& globalData, NPRuntimeObjectMap* objectMap, JSObject* jsObject) |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 73 | { |
| 74 | ASSERT(!m_objectMap); |
| 75 | ASSERT(!m_jsObject); |
| 76 | |
| 77 | m_objectMap = objectMap; |
oliver@apple.com | 8d85705 | 2011-02-15 23:54:06 +0000 | [diff] [blame] | 78 | m_jsObject.set(globalData, jsObject); |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static Identifier identifierFromIdentifierRep(ExecState* exec, IdentifierRep* identifierRep) |
| 82 | { |
| 83 | ASSERT(identifierRep->isString()); |
| 84 | |
| 85 | const char* string = identifierRep->string(); |
| 86 | int length = strlen(string); |
| 87 | |
| 88 | return Identifier(exec, String::fromUTF8WithLatin1Fallback(string, length).impl()); |
| 89 | } |
| 90 | |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 91 | bool NPJSObject::hasMethod(NPIdentifier methodName) |
| 92 | { |
| 93 | IdentifierRep* identifierRep = static_cast<IdentifierRep*>(methodName); |
| 94 | |
| 95 | if (!identifierRep->isString()) |
| 96 | return false; |
| 97 | |
| 98 | ExecState* exec = m_objectMap->globalExec(); |
| 99 | if (!exec) |
| 100 | return false; |
| 101 | |
mhahnenberg@apple.com | e16f809 | 2012-06-27 23:08:26 +0000 | [diff] [blame] | 102 | JSLockHolder lock(exec); |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 103 | |
| 104 | JSValue value = m_jsObject->get(exec, identifierFromIdentifierRep(exec, identifierRep)); |
| 105 | exec->clearException(); |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 106 | |
| 107 | CallData callData; |
andersca@apple.com | e8bdca2 | 2010-07-28 23:38:24 +0000 | [diff] [blame] | 108 | return getCallData(value, callData) != CallTypeNone; |
| 109 | } |
| 110 | |
| 111 | bool NPJSObject::invoke(NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) |
| 112 | { |
| 113 | IdentifierRep* identifierRep = static_cast<IdentifierRep*>(methodName); |
| 114 | |
| 115 | if (!identifierRep->isString()) |
| 116 | return false; |
| 117 | |
| 118 | ExecState* exec = m_objectMap->globalExec(); |
| 119 | if (!exec) |
| 120 | return false; |
| 121 | |
mhahnenberg@apple.com | e16f809 | 2012-06-27 23:08:26 +0000 | [diff] [blame] | 122 | JSLockHolder lock(exec); |
andersca@apple.com | e8bdca2 | 2010-07-28 23:38:24 +0000 | [diff] [blame] | 123 | |
| 124 | JSValue function = m_jsObject->get(exec, identifierFromIdentifierRep(exec, identifierRep)); |
andersca@apple.com | 8f8a7d5 | 2010-07-29 19:31:06 +0000 | [diff] [blame] | 125 | return invoke(exec, m_objectMap->globalObject(), function, arguments, argumentCount, result); |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 126 | } |
| 127 | |
andersca@apple.com | 1039e40 | 2010-07-30 21:43:48 +0000 | [diff] [blame] | 128 | bool NPJSObject::invokeDefault(const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 129 | { |
| 130 | ExecState* exec = m_objectMap->globalExec(); |
| 131 | if (!exec) |
andersca@apple.com | e8bdca2 | 2010-07-28 23:38:24 +0000 | [diff] [blame] | 132 | return false; |
| 133 | |
mhahnenberg@apple.com | e16f809 | 2012-06-27 23:08:26 +0000 | [diff] [blame] | 134 | JSLockHolder lock(exec); |
andersca@apple.com | e8bdca2 | 2010-07-28 23:38:24 +0000 | [diff] [blame] | 135 | |
oliver@apple.com | 8d85705 | 2011-02-15 23:54:06 +0000 | [diff] [blame] | 136 | JSValue function = m_jsObject.get(); |
andersca@apple.com | 8f8a7d5 | 2010-07-29 19:31:06 +0000 | [diff] [blame] | 137 | return invoke(exec, m_objectMap->globalObject(), function, arguments, argumentCount, result); |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 138 | } |
| 139 | |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 140 | bool NPJSObject::hasProperty(NPIdentifier identifier) |
| 141 | { |
| 142 | IdentifierRep* identifierRep = static_cast<IdentifierRep*>(identifier); |
| 143 | |
| 144 | ExecState* exec = m_objectMap->globalExec(); |
| 145 | if (!exec) |
| 146 | return false; |
| 147 | |
mhahnenberg@apple.com | e16f809 | 2012-06-27 23:08:26 +0000 | [diff] [blame] | 148 | JSLockHolder lock(exec); |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 149 | |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 150 | bool result; |
| 151 | if (identifierRep->isString()) |
| 152 | result = m_jsObject->hasProperty(exec, identifierFromIdentifierRep(exec, identifierRep)); |
| 153 | else |
| 154 | result = m_jsObject->hasProperty(exec, identifierRep->number()); |
| 155 | |
| 156 | exec->clearException(); |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 157 | return result; |
| 158 | } |
| 159 | |
andersca@apple.com | 5b2497c | 2010-07-28 21:30:11 +0000 | [diff] [blame] | 160 | bool NPJSObject::getProperty(NPIdentifier propertyName, NPVariant* result) |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 161 | { |
andersca@apple.com | 5b2497c | 2010-07-28 21:30:11 +0000 | [diff] [blame] | 162 | IdentifierRep* identifierRep = static_cast<IdentifierRep*>(propertyName); |
| 163 | |
| 164 | ExecState* exec = m_objectMap->globalExec(); |
| 165 | if (!exec) |
| 166 | return false; |
| 167 | |
mhahnenberg@apple.com | e16f809 | 2012-06-27 23:08:26 +0000 | [diff] [blame] | 168 | JSLockHolder lock(exec); |
andersca@apple.com | 5b2497c | 2010-07-28 21:30:11 +0000 | [diff] [blame] | 169 | JSValue jsResult; |
| 170 | if (identifierRep->isString()) |
| 171 | jsResult = m_jsObject->get(exec, identifierFromIdentifierRep(exec, identifierRep)); |
| 172 | else |
| 173 | jsResult = m_jsObject->get(exec, identifierRep->number()); |
| 174 | |
| 175 | m_objectMap->convertJSValueToNPVariant(exec, jsResult, *result); |
| 176 | exec->clearException(); |
| 177 | return true; |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 178 | } |
| 179 | |
andersca@apple.com | 6429f94 | 2010-07-29 22:42:17 +0000 | [diff] [blame] | 180 | bool NPJSObject::setProperty(NPIdentifier propertyName, const NPVariant* value) |
| 181 | { |
| 182 | IdentifierRep* identifierRep = static_cast<IdentifierRep*>(propertyName); |
| 183 | |
| 184 | ExecState* exec = m_objectMap->globalExec(); |
| 185 | if (!exec) |
| 186 | return false; |
| 187 | |
mhahnenberg@apple.com | e16f809 | 2012-06-27 23:08:26 +0000 | [diff] [blame] | 188 | JSLockHolder lock(exec); |
andersca@apple.com | 6429f94 | 2010-07-29 22:42:17 +0000 | [diff] [blame] | 189 | |
| 190 | JSValue jsValue = m_objectMap->convertNPVariantToJSValue(exec, m_objectMap->globalObject(), *value); |
| 191 | if (identifierRep->isString()) { |
| 192 | PutPropertySlot slot; |
mhahnenberg@apple.com | 3951278 | 2011-10-26 00:56:55 +0000 | [diff] [blame] | 193 | m_jsObject->methodTable()->put(m_jsObject.get(), exec, identifierFromIdentifierRep(exec, identifierRep), jsValue, slot); |
andersca@apple.com | 6429f94 | 2010-07-29 22:42:17 +0000 | [diff] [blame] | 194 | } else |
barraclough@apple.com | b1db28d8 | 2012-03-06 07:23:21 +0000 | [diff] [blame] | 195 | m_jsObject->methodTable()->putByIndex(m_jsObject.get(), exec, identifierRep->number(), jsValue, false); |
andersca@apple.com | 6429f94 | 2010-07-29 22:42:17 +0000 | [diff] [blame] | 196 | exec->clearException(); |
| 197 | |
| 198 | return true; |
| 199 | } |
| 200 | |
andersca@apple.com | 01dbfa0 | 2010-08-01 21:02:46 +0000 | [diff] [blame] | 201 | bool NPJSObject::removeProperty(NPIdentifier propertyName) |
| 202 | { |
| 203 | IdentifierRep* identifierRep = static_cast<IdentifierRep*>(propertyName); |
| 204 | |
| 205 | ExecState* exec = m_objectMap->globalExec(); |
| 206 | if (!exec) |
| 207 | return false; |
| 208 | |
mhahnenberg@apple.com | e16f809 | 2012-06-27 23:08:26 +0000 | [diff] [blame] | 209 | JSLockHolder lock(exec); |
andersca@apple.com | 01dbfa0 | 2010-08-01 21:02:46 +0000 | [diff] [blame] | 210 | if (identifierRep->isString()) { |
| 211 | Identifier identifier = identifierFromIdentifierRep(exec, identifierRep); |
| 212 | |
| 213 | if (!m_jsObject->hasProperty(exec, identifier)) { |
| 214 | exec->clearException(); |
| 215 | return false; |
| 216 | } |
| 217 | |
mhahnenberg@apple.com | c0f87c1 | 2011-10-26 01:49:00 +0000 | [diff] [blame] | 218 | m_jsObject->methodTable()->deleteProperty(m_jsObject.get(), exec, identifier); |
andersca@apple.com | 01dbfa0 | 2010-08-01 21:02:46 +0000 | [diff] [blame] | 219 | } else { |
| 220 | if (!m_jsObject->hasProperty(exec, identifierRep->number())) { |
| 221 | exec->clearException(); |
| 222 | return false; |
| 223 | } |
| 224 | |
mhahnenberg@apple.com | c0f87c1 | 2011-10-26 01:49:00 +0000 | [diff] [blame] | 225 | m_jsObject->methodTable()->deletePropertyByIndex(m_jsObject.get(), exec, identifierRep->number()); |
andersca@apple.com | 01dbfa0 | 2010-08-01 21:02:46 +0000 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | exec->clearException(); |
| 229 | return true; |
| 230 | } |
| 231 | |
andersca@apple.com | 022916b | 2010-07-29 22:21:43 +0000 | [diff] [blame] | 232 | bool NPJSObject::enumerate(NPIdentifier** identifiers, uint32_t* identifierCount) |
| 233 | { |
| 234 | ExecState* exec = m_objectMap->globalExec(); |
| 235 | if (!exec) |
| 236 | return false; |
| 237 | |
mhahnenberg@apple.com | e16f809 | 2012-06-27 23:08:26 +0000 | [diff] [blame] | 238 | JSLockHolder lock(exec); |
andersca@apple.com | 022916b | 2010-07-29 22:21:43 +0000 | [diff] [blame] | 239 | |
| 240 | PropertyNameArray propertyNames(exec); |
mhahnenberg@apple.com | 2358ae1 | 2011-11-04 01:32:18 +0000 | [diff] [blame] | 241 | m_jsObject->methodTable()->getPropertyNames(m_jsObject.get(), exec, propertyNames, ExcludeDontEnumProperties); |
andersca@apple.com | 022916b | 2010-07-29 22:21:43 +0000 | [diff] [blame] | 242 | |
andersca@apple.com | a1247b7 | 2010-11-02 21:18:18 +0000 | [diff] [blame] | 243 | NPIdentifier* nameIdentifiers = npnMemNewArray<NPIdentifier>(propertyNames.size()); |
andersca@apple.com | 022916b | 2010-07-29 22:21:43 +0000 | [diff] [blame] | 244 | |
| 245 | for (size_t i = 0; i < propertyNames.size(); ++i) |
benjamin@webkit.org | c9b7a20 | 2012-09-08 05:46:29 +0000 | [diff] [blame^] | 246 | nameIdentifiers[i] = static_cast<NPIdentifier>(IdentifierRep::get(propertyNames[i].string().utf8().data())); |
andersca@apple.com | 022916b | 2010-07-29 22:21:43 +0000 | [diff] [blame] | 247 | |
| 248 | *identifiers = nameIdentifiers; |
| 249 | *identifierCount = propertyNames.size(); |
| 250 | |
| 251 | return true; |
| 252 | } |
| 253 | |
andersca@apple.com | 1039e40 | 2010-07-30 21:43:48 +0000 | [diff] [blame] | 254 | bool NPJSObject::construct(const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 255 | { |
| 256 | ExecState* exec = m_objectMap->globalExec(); |
| 257 | if (!exec) |
| 258 | return false; |
| 259 | |
mhahnenberg@apple.com | e16f809 | 2012-06-27 23:08:26 +0000 | [diff] [blame] | 260 | JSLockHolder lock(exec); |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 261 | |
| 262 | ConstructData constructData; |
oliver@apple.com | 8d85705 | 2011-02-15 23:54:06 +0000 | [diff] [blame] | 263 | ConstructType constructType = getConstructData(m_jsObject.get(), constructData); |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 264 | if (constructType == ConstructTypeNone) |
| 265 | return false; |
| 266 | |
| 267 | // Convert the passed in arguments. |
| 268 | MarkedArgumentBuffer argumentList; |
| 269 | for (uint32_t i = 0; i < argumentCount; ++i) |
andersca@apple.com | 8f8a7d5 | 2010-07-29 19:31:06 +0000 | [diff] [blame] | 270 | argumentList.append(m_objectMap->convertNPVariantToJSValue(exec, m_objectMap->globalObject(), arguments[i])); |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 271 | |
| 272 | exec->globalData().timeoutChecker.start(); |
oliver@apple.com | 8d85705 | 2011-02-15 23:54:06 +0000 | [diff] [blame] | 273 | JSValue value = JSC::construct(exec, m_jsObject.get(), constructType, constructData, argumentList); |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 274 | exec->globalData().timeoutChecker.stop(); |
| 275 | |
| 276 | // Convert and return the new object. |
| 277 | m_objectMap->convertJSValueToNPVariant(exec, value, *result); |
| 278 | exec->clearException(); |
| 279 | |
| 280 | return true; |
| 281 | } |
| 282 | |
andersca@apple.com | 8f8a7d5 | 2010-07-29 19:31:06 +0000 | [diff] [blame] | 283 | bool NPJSObject::invoke(ExecState* exec, JSGlobalObject* globalObject, JSValue function, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 284 | { |
| 285 | CallData callData; |
| 286 | CallType callType = getCallData(function, callData); |
| 287 | if (callType == CallTypeNone) |
| 288 | return false; |
| 289 | |
| 290 | // Convert the passed in arguments. |
| 291 | MarkedArgumentBuffer argumentList; |
| 292 | for (uint32_t i = 0; i < argumentCount; ++i) |
andersca@apple.com | 8f8a7d5 | 2010-07-29 19:31:06 +0000 | [diff] [blame] | 293 | argumentList.append(m_objectMap->convertNPVariantToJSValue(exec, globalObject, arguments[i])); |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 294 | |
| 295 | exec->globalData().timeoutChecker.start(); |
mhahnenberg@apple.com | c93887c | 2011-10-27 17:01:38 +0000 | [diff] [blame] | 296 | JSValue value = JSC::call(exec, function, callType, callData, m_jsObject->methodTable()->toThisObject(m_jsObject.get(), exec), argumentList); |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 297 | exec->globalData().timeoutChecker.stop(); |
| 298 | |
| 299 | // Convert and return the result of the function call. |
| 300 | m_objectMap->convertJSValueToNPVariant(exec, value, *result); |
| 301 | exec->clearException(); |
| 302 | |
| 303 | return true; |
| 304 | } |
| 305 | |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 306 | NPClass* NPJSObject::npClass() |
| 307 | { |
| 308 | static NPClass npClass = { |
| 309 | NP_CLASS_STRUCT_VERSION, |
| 310 | NP_Allocate, |
| 311 | NP_Deallocate, |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 312 | 0, |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 313 | NP_HasMethod, |
| 314 | NP_Invoke, |
| 315 | NP_InvokeDefault, |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 316 | NP_HasProperty, |
| 317 | NP_GetProperty, |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 318 | NP_SetProperty, |
andersca@apple.com | 01dbfa0 | 2010-08-01 21:02:46 +0000 | [diff] [blame] | 319 | NP_RemoveProperty, |
andersca@apple.com | 022916b | 2010-07-29 22:21:43 +0000 | [diff] [blame] | 320 | NP_Enumerate, |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 321 | NP_Construct |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 322 | }; |
| 323 | |
| 324 | return &npClass; |
| 325 | } |
| 326 | |
andersca@apple.com | 004117f | 2010-11-01 21:10:56 +0000 | [diff] [blame] | 327 | NPObject* NPJSObject::NP_Allocate(NPP npp, NPClass*) |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 328 | { |
| 329 | ASSERT_UNUSED(npp, !npp); |
| 330 | |
| 331 | return new NPJSObject; |
| 332 | } |
| 333 | |
| 334 | void NPJSObject::NP_Deallocate(NPObject* npObject) |
| 335 | { |
| 336 | NPJSObject* npJSObject = toNPJSObject(npObject); |
| 337 | delete npJSObject; |
| 338 | } |
| 339 | |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 340 | bool NPJSObject::NP_HasMethod(NPObject* npObject, NPIdentifier methodName) |
| 341 | { |
| 342 | return toNPJSObject(npObject)->hasMethod(methodName); |
| 343 | } |
| 344 | |
andersca@apple.com | e8bdca2 | 2010-07-28 23:38:24 +0000 | [diff] [blame] | 345 | bool NPJSObject::NP_Invoke(NPObject* npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 346 | { |
andersca@apple.com | e8bdca2 | 2010-07-28 23:38:24 +0000 | [diff] [blame] | 347 | return toNPJSObject(npObject)->invoke(methodName, arguments, argumentCount, result); |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 348 | } |
| 349 | |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 350 | bool NPJSObject::NP_InvokeDefault(NPObject* npObject, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 351 | { |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 352 | return toNPJSObject(npObject)->invokeDefault(arguments, argumentCount, result); |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 353 | } |
| 354 | |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 355 | bool NPJSObject::NP_HasProperty(NPObject* npObject, NPIdentifier propertyName) |
| 356 | { |
| 357 | return toNPJSObject(npObject)->hasProperty(propertyName); |
| 358 | } |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 359 | |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 360 | bool NPJSObject::NP_GetProperty(NPObject* npObject, NPIdentifier propertyName, NPVariant* result) |
| 361 | { |
| 362 | return toNPJSObject(npObject)->getProperty(propertyName, result); |
| 363 | } |
| 364 | |
andersca@apple.com | 6429f94 | 2010-07-29 22:42:17 +0000 | [diff] [blame] | 365 | bool NPJSObject::NP_SetProperty(NPObject* npObject, NPIdentifier propertyName, const NPVariant* value) |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 366 | { |
andersca@apple.com | 6429f94 | 2010-07-29 22:42:17 +0000 | [diff] [blame] | 367 | return toNPJSObject(npObject)->setProperty(propertyName, value); |
andersca@apple.com | e650933 | 2010-07-28 23:03:25 +0000 | [diff] [blame] | 368 | } |
| 369 | |
andersca@apple.com | 01dbfa0 | 2010-08-01 21:02:46 +0000 | [diff] [blame] | 370 | bool NPJSObject::NP_RemoveProperty(NPObject* npObject, NPIdentifier propertyName) |
| 371 | { |
| 372 | return toNPJSObject(npObject)->removeProperty(propertyName); |
| 373 | } |
| 374 | |
andersca@apple.com | 022916b | 2010-07-29 22:21:43 +0000 | [diff] [blame] | 375 | bool NPJSObject::NP_Enumerate(NPObject* npObject, NPIdentifier** identifiers, uint32_t* identifierCount) |
| 376 | { |
| 377 | return toNPJSObject(npObject)->enumerate(identifiers, identifierCount); |
| 378 | } |
| 379 | |
andersca@apple.com | e40da10 | 2010-07-29 00:14:08 +0000 | [diff] [blame] | 380 | bool NPJSObject::NP_Construct(NPObject* npObject, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result) |
| 381 | { |
| 382 | return toNPJSObject(npObject)->construct(arguments, argumentCount, result); |
| 383 | } |
| 384 | |
andersca@apple.com | 861e84a | 2010-07-27 19:29:45 +0000 | [diff] [blame] | 385 | } // namespace WebKit |
aestes@apple.com | 022b378 | 2012-05-16 03:55:58 +0000 | [diff] [blame] | 386 | |
| 387 | #endif // ENABLE(NETSCAPE_PLUGIN_API) |