1 /* 2 * Copyright (C) 2008, 2009 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. ``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. 24 */ 25 26 #ifndef JSQuarantinedObjectWrapper_h 27 #define JSQuarantinedObjectWrapper_h 28 29 #include <runtime/JSObject.h> 30 31 namespace WebCore { 32 33 class JSQuarantinedObjectWrapper : public JSC::JSObject { 34 public: 35 static JSQuarantinedObjectWrapper* asWrapper(JSC::JSValue); 36 37 virtual ~JSQuarantinedObjectWrapper(); 38 unwrappedObject()39 virtual JSC::JSObject* unwrappedObject() { return m_unwrappedObject; } 40 unwrappedGlobalObject()41 JSC::JSGlobalObject* unwrappedGlobalObject() const { return m_unwrappedGlobalObject; }; 42 JSC::ExecState* unwrappedExecState() const; 43 44 bool allowsUnwrappedAccessFrom(JSC::ExecState*) const; 45 46 static const JSC::ClassInfo s_info; 47 createStructure(JSC::JSValue proto)48 static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue proto) 49 { 50 return JSC::Structure::create(proto, JSC::TypeInfo(JSC::ObjectType, JSC::ImplementsHasInstance | JSC::OverridesHasInstance)); 51 } 52 53 protected: 54 JSQuarantinedObjectWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, PassRefPtr<JSC::Structure>); 55 56 virtual void markChildren(JSC::MarkStack&); 57 58 private: 59 virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); 60 virtual bool getOwnPropertySlot(JSC::ExecState*, unsigned, JSC::PropertySlot&); 61 62 virtual void put(JSC::ExecState*, const JSC::Identifier&, JSC::JSValue, JSC::PutPropertySlot&); 63 virtual void put(JSC::ExecState*, unsigned, JSC::JSValue); 64 65 virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier&); 66 virtual bool deleteProperty(JSC::ExecState*, unsigned); 67 68 virtual JSC::CallType getCallData(JSC::CallData&); 69 virtual JSC::ConstructType getConstructData(JSC::ConstructData&); 70 71 virtual bool hasInstance(JSC::ExecState*, JSC::JSValue, JSC::JSValue proto); 72 73 virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); 74 className()75 virtual JSC::UString className() const { return m_unwrappedObject->className(); } 76 allowsGetProperty()77 virtual bool allowsGetProperty() const { return false; } allowsSetProperty()78 virtual bool allowsSetProperty() const { return false; } allowsDeleteProperty()79 virtual bool allowsDeleteProperty() const { return false; } allowsConstruct()80 virtual bool allowsConstruct() const { return false; } allowsHasInstance()81 virtual bool allowsHasInstance() const { return false; } allowsCallAsFunction()82 virtual bool allowsCallAsFunction() const { return false; } allowsGetPropertyNames()83 virtual bool allowsGetPropertyNames() const { return false; } 84 85 virtual JSC::JSValue prepareIncomingValue(JSC::ExecState* unwrappedExec, JSC::JSValue unwrappedValue) const = 0; 86 virtual JSC::JSValue wrapOutgoingValue(JSC::ExecState* unwrappedExec, JSC::JSValue unwrappedValue) const = 0; 87 88 static JSC::JSValue cachedValueGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); 89 90 void transferExceptionToExecState(JSC::ExecState*) const; 91 92 static JSC::JSValue JSC_HOST_CALL call(JSC::ExecState*, JSC::JSObject* function, JSC::JSValue thisValue, const JSC::ArgList&); 93 static JSC::JSObject* construct(JSC::ExecState*, JSC::JSObject*, const JSC::ArgList&); 94 95 JSC::JSGlobalObject* m_unwrappedGlobalObject; 96 JSC::JSObject* m_unwrappedObject; 97 }; 98 99 } // namespace WebCore 100 101 #endif // JSQuarantinedObjectWrapper_h 102