2
* Copyright (C) 2010 Apple Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
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.
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.
29
#if ENABLE(NETSCAPE_PLUGIN_API)
31
#include <JavaScriptCore/JSGlobalObject.h>
32
#include <JavaScriptCore/JSObject.h>
33
#include <JavaScriptCore/ObjectPrototype.h>
35
typedef void* NPIdentifier;
40
class NPRuntimeObjectMap;
42
// JSNPObject is a JSObject that wraps an NPObject.
44
class JSNPObject : public JSC::JSDestructibleObject {
46
typedef JSC::JSDestructibleObject Base;
48
static JSNPObject* create(JSC::JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject)
50
JSC::Structure* structure = createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype());
51
JSNPObject* object = new (JSC::allocateCell<JSNPObject>(globalObject->globalData().heap)) JSNPObject(globalObject, structure, objectMap, npObject);
52
object->finishCreation(globalObject);
57
static void destroy(JSCell*);
61
// Used to invalidate an NPObject asynchronously.
62
NPObject* leakNPObject();
64
JSC::JSValue callMethod(JSC::ExecState*, NPIdentifier methodName);
65
JSC::JSValue callObject(JSC::ExecState*);
66
JSC::JSValue callConstructor(JSC::ExecState*);
68
static const JSC::ClassInfo s_info;
70
NPObject* npObject() const { return m_npObject; }
73
void finishCreation(JSC::JSGlobalObject*);
76
JSNPObject(JSC::JSGlobalObject*, JSC::Structure*, NPRuntimeObjectMap*, NPObject*);
78
static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | JSObject::StructureFlags;
80
static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
82
return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);
85
static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&);
86
static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
88
static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&);
89
static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertyDescriptor&);
90
static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&);
92
static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName);
93
static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName);
95
bool deleteProperty(JSC::ExecState*, NPIdentifier propertyName);
97
static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);
99
static JSC::JSValue propertyGetter(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
100
static JSC::JSValue methodGetter(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
101
static JSC::JSObject* throwInvalidAccessError(JSC::ExecState*);
103
NPRuntimeObjectMap* m_objectMap;
104
NPObject* m_npObject;
107
} // namespace WebKit
109
#endif // ENABLE(NETSCAPE_PLUGIN_API)
111
#endif // JSNPObject_h