util/src/script/bridge/qscriptglobalobject_p.h
changeset 7 f7bc934e204c
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtScript module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL-ONLY$
       
    10 ** GNU Lesser General Public License Usage
       
    11 ** This file may be used under the terms of the GNU Lesser
       
    12 ** General Public License version 2.1 as published by the Free Software
       
    13 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    14 ** packaging of this file.  Please review the following information to
       
    15 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    16 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    17 **
       
    18 ** If you have questions regarding the use of this file, please contact
       
    19 ** Nokia at qt-info@nokia.com.
       
    20 ** $QT_END_LICENSE$
       
    21 **
       
    22 ****************************************************************************/
       
    23 
       
    24 #ifndef QSCRIPTGLOBALOBJECT_P_H
       
    25 #define QSCRIPTGLOBALOBJECT_P_H
       
    26 
       
    27 //
       
    28 //  W A R N I N G
       
    29 //  -------------
       
    30 //
       
    31 // This file is not part of the Qt API.  It exists purely as an
       
    32 // implementation detail.  This header file may change from version to
       
    33 // version without notice, or even be removed.
       
    34 //
       
    35 // We mean it.
       
    36 //
       
    37 
       
    38 #include <QtCore/qobjectdefs.h>
       
    39 
       
    40 #include "JSGlobalObject.h"
       
    41 
       
    42 QT_BEGIN_NAMESPACE
       
    43 
       
    44 namespace QScript
       
    45 {
       
    46 
       
    47 class GlobalObject : public JSC::JSGlobalObject
       
    48 {
       
    49 public:
       
    50     GlobalObject();
       
    51     virtual ~GlobalObject();
       
    52     virtual JSC::UString className() const { return "global"; }
       
    53     virtual void markChildren(JSC::MarkStack&);
       
    54     virtual bool getOwnPropertySlot(JSC::ExecState*,
       
    55                                     const JSC::Identifier& propertyName,
       
    56                                     JSC::PropertySlot&);
       
    57     virtual void put(JSC::ExecState* exec, const JSC::Identifier& propertyName,
       
    58                      JSC::JSValue, JSC::PutPropertySlot&);
       
    59     virtual void putWithAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName,
       
    60                                    JSC::JSValue value, unsigned attributes);
       
    61     virtual bool deleteProperty(JSC::ExecState*,
       
    62                                 const JSC::Identifier& propertyName,
       
    63                                 bool checkDontDelete = true);
       
    64     virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&,
       
    65                                        unsigned&) const;
       
    66     virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&,
       
    67                                      bool includeNonEnumerable = false);
       
    68     virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes = 0);
       
    69     virtual void defineSetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes = 0);
       
    70     virtual JSC::JSValue lookupGetter(JSC::ExecState*, const JSC::Identifier& propertyName);
       
    71     virtual JSC::JSValue lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName);
       
    72 
       
    73 public:
       
    74     JSC::JSObject *customGlobalObject;
       
    75 };
       
    76 
       
    77 class OriginalGlobalObjectProxy : public JSC::JSObject
       
    78 {
       
    79 public:
       
    80     explicit OriginalGlobalObjectProxy(WTF::PassRefPtr<JSC::Structure> sid,
       
    81                                        JSC::JSGlobalObject *object)
       
    82         : JSC::JSObject(sid), originalGlobalObject(object)
       
    83     {}
       
    84     virtual ~OriginalGlobalObjectProxy()
       
    85     {}
       
    86     virtual JSC::UString className() const
       
    87     { return originalGlobalObject->className(); }
       
    88     virtual void markChildren(JSC::MarkStack& markStack)
       
    89     {
       
    90         markStack.append(originalGlobalObject);
       
    91         JSC::JSObject::markChildren(markStack);
       
    92     }
       
    93     virtual bool getOwnPropertySlot(JSC::ExecState* exec,
       
    94                                     const JSC::Identifier& propertyName,
       
    95                                     JSC::PropertySlot& slot)
       
    96     { return originalGlobalObject->JSC::JSGlobalObject::getOwnPropertySlot(exec, propertyName, slot); }
       
    97     virtual void put(JSC::ExecState* exec, const JSC::Identifier& propertyName,
       
    98                      JSC::JSValue value, JSC::PutPropertySlot& slot)
       
    99     { originalGlobalObject->JSC::JSGlobalObject::put(exec, propertyName, value, slot); }
       
   100     virtual void putWithAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue value, unsigned attributes)
       
   101     { originalGlobalObject->JSC::JSGlobalObject::putWithAttributes(exec, propertyName, value, attributes); }
       
   102     virtual bool deleteProperty(JSC::ExecState* exec,
       
   103                                 const JSC::Identifier& propertyName, bool checkDontDelete = true)
       
   104     { return originalGlobalObject->JSC::JSGlobalObject::deleteProperty(exec, propertyName, checkDontDelete); }
       
   105     virtual bool getPropertyAttributes(JSC::ExecState* exec, const JSC::Identifier& propertyName,
       
   106                                        unsigned& attributes) const
       
   107     { return originalGlobalObject->JSC::JSGlobalObject::getPropertyAttributes(exec, propertyName, attributes); }
       
   108     virtual void getOwnPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArray& propertyNames, bool includeNonEnumerable = false)
       
   109     { originalGlobalObject->JSC::JSGlobalObject::getOwnPropertyNames(exec, propertyNames, includeNonEnumerable); }
       
   110     virtual void defineGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes)
       
   111     { originalGlobalObject->JSC::JSGlobalObject::defineGetter(exec, propertyName, getterFunction, attributes); }
       
   112     virtual void defineSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes)
       
   113     { originalGlobalObject->JSC::JSGlobalObject::defineSetter(exec, propertyName, setterFunction, attributes); }
       
   114     virtual JSC::JSValue lookupGetter(JSC::ExecState* exec, const JSC::Identifier& propertyName)
       
   115     { return originalGlobalObject->JSC::JSGlobalObject::lookupGetter(exec, propertyName); }
       
   116     virtual JSC::JSValue lookupSetter(JSC::ExecState* exec, const JSC::Identifier& propertyName)
       
   117     { return originalGlobalObject->JSC::JSGlobalObject::lookupSetter(exec, propertyName); }
       
   118 private:
       
   119     JSC::JSGlobalObject *originalGlobalObject;
       
   120 };
       
   121 
       
   122 } // namespace QScript
       
   123 
       
   124 QT_END_NAMESPACE
       
   125 
       
   126 #endif