00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KJSEMBEDJSOBJECTPROXY_H
00023 #define KJSEMBEDJSOBJECTPROXY_H
00024
00025 #include <qguardedptr.h>
00026 #include <qcstring.h>
00027 #include <qwidget.h>
00028
00029 #include <kjs/object.h>
00030 #include <kjsembed/jsproxy.h>
00031 #include <kjsembed/jsbinding.h>
00032
00033 namespace KJS { class Interpreter; }
00034
00035 namespace KJSEmbed {
00036
00037 namespace Bindings { class JSObjectProxyImp; }
00038
00039 class JSSecurityPolicy;
00040 class KJSEmbedPart;
00041 class JSObjectEventProxy;
00042
00080 class JSObjectProxy : public JSProxy
00081 {
00082 public:
00087 JSObjectProxy( KJSEmbedPart *part, QObject *target );
00088
00094 JSObjectProxy( KJSEmbedPart *part, QObject *target, QObject *root );
00095
00102 JSObjectProxy( KJSEmbedPart *part, QObject *target, QObject *root, const JSSecurityPolicy *sp );
00103
00104 virtual ~JSObjectProxy() {}
00105
00107 KJSEmbedPart *part() const { return jspart; }
00108
00110 KJS::Interpreter *interpreter() const { return js; }
00111
00113 QObject *rootObject() const { return root; }
00114
00116 QObject *object() const { return obj; }
00117
00119 QWidget *widget() const
00120 {
00121 QObject *w = obj;
00122 return (w && w->isWidgetType()) ? static_cast<QWidget *>(w) : 0;
00123 }
00124
00125 void *toVoidStar() { return obj; }
00126
00128 bool inherits( const char *clazz ) { return obj->isA( clazz ); }
00129
00131 const JSSecurityPolicy *securityPolicy() const { return policy; }
00132
00137 void setSecurityPolicy( const JSSecurityPolicy *sp );
00138
00140 virtual KJS::Value get( KJS::ExecState *exec, const KJS::Identifier &p ) const;
00141
00143 virtual void put( KJS::ExecState *exec, const KJS::Identifier &p,
00144 const KJS::Value &v, int attr = KJS::None );
00145
00147 virtual KJS::UString toString( KJS::ExecState *exec ) const;
00148
00159 virtual void addBindings( KJS::ExecState *exec, KJS::Object &object );
00160
00161 protected:
00162 void addBindingsClass( KJS::ExecState *exec, KJS::Object &object );
00163
00167 void addBindingsEnum( KJS::ExecState *exec, KJS::Object &object );
00168
00172 void addBindingsSlots( KJS::ExecState *exec, KJS::Object &object );
00173
00174
00175 private:
00176 bool isAllowed( KJS::Interpreter *js ) const;
00177
00178 void addSlotBinding( const QCString &name, KJS::ExecState *exec, KJS::Object &object );
00179
00180 private:
00181 KJSEmbedPart *jspart;
00182 KJS::Interpreter *js;
00183 QGuardedPtr<QObject> obj;
00184 QGuardedPtr<QObject> root;
00185 QGuardedPtr<JSObjectEventProxy> evproxy;
00186 const JSSecurityPolicy *policy;
00187 class JSObjectProxyPrivate *d;
00188 friend class Bindings::JSObjectProxyImp;
00189 };
00190
00191 }
00192
00193 #endif // KJSEMBEDJSOBJECTPROXY_H
00194
00195
00196
00197