2 * Copyright (C) 2008 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. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef JSQuarantinedObjectWrapper_h
27 #define JSQuarantinedObjectWrapper_h
29 #include <kjs/JSObject.h>
33 class JSQuarantinedObjectWrapper : public JSC::JSObject {
35 static JSQuarantinedObjectWrapper* asWrapper(JSC::JSValue*);
37 virtual ~JSQuarantinedObjectWrapper();
39 JSC::JSObject* unwrappedObject() const { return m_unwrappedObject; }
40 JSC::JSGlobalObject* unwrappedGlobalObject() const { return m_unwrappedGlobalObject; };
41 JSC::ExecState* unwrappedExecState() const;
43 bool allowsUnwrappedAccessFrom(const JSC::ExecState*) const;
45 static const JSC::ClassInfo s_info;
47 static PassRefPtr<JSC::StructureID> createStructureID(JSC::JSValue* proto)
49 return JSC::StructureID::create(proto, JSC::TypeInfo(JSC::ObjectType, JSC::ImplementsHasInstance | JSC::OverridesHasInstance));
53 JSQuarantinedObjectWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, PassRefPtr<JSC::StructureID>);
58 virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
59 virtual bool getOwnPropertySlot(JSC::ExecState*, unsigned, JSC::PropertySlot&);
61 virtual void put(JSC::ExecState*, const JSC::Identifier&, JSC::JSValue*, JSC::PutPropertySlot&);
62 virtual void put(JSC::ExecState*, unsigned, JSC::JSValue*);
64 virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier&);
65 virtual bool deleteProperty(JSC::ExecState*, unsigned);
67 virtual JSC::CallType getCallData(JSC::CallData&);
68 virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
70 virtual bool hasInstance(JSC::ExecState*, JSC::JSValue*, JSC::JSValue* proto);
72 virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);
74 virtual JSC::UString className() const { return m_unwrappedObject->className(); }
76 virtual bool allowsGetProperty() const { return false; }
77 virtual bool allowsSetProperty() const { return false; }
78 virtual bool allowsDeleteProperty() const { return false; }
79 virtual bool allowsConstruct() const { return false; }
80 virtual bool allowsHasInstance() const { return false; }
81 virtual bool allowsCallAsFunction() const { return false; }
82 virtual bool allowsGetPropertyNames() const { return false; }
84 virtual JSC::JSValue* prepareIncomingValue(JSC::ExecState* unwrappedExec, JSC::JSValue* unwrappedValue) const = 0;
85 virtual JSC::JSValue* wrapOutgoingValue(JSC::ExecState* unwrappedExec, JSC::JSValue* unwrappedValue) const = 0;
87 static JSC::JSValue* cachedValueGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&);
89 void transferExceptionToExecState(JSC::ExecState*) const;
91 static JSC::JSValue* call(JSC::ExecState*, JSC::JSObject* function, JSC::JSValue* thisValue, const JSC::ArgList&);
92 static JSC::JSObject* construct(JSC::ExecState*, JSC::JSObject*, const JSC::ArgList&);
94 JSC::JSGlobalObject* m_unwrappedGlobalObject;
95 JSC::JSObject* m_unwrappedObject;
98 } // namespace WebCore
100 #endif // JSQuarantinedObjectWrapper_h