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
00079 class JSObjectProxy : public JSProxy
00080 {
00081 public:
00086 JSObjectProxy( KJSEmbedPart *part, QObject *target );
00087
00093 JSObjectProxy( KJSEmbedPart *part, QObject *target, QObject *root );
00094
00101 JSObjectProxy( KJSEmbedPart *part, QObject *target, QObject *root, const JSSecurityPolicy *sp );
00102
00103 virtual ~JSObjectProxy() {}
00104
00106 KJSEmbedPart *part() const { return jspart; }
00107
00109 KJS::Interpreter *interpreter() const { return js; }
00110
00112 QObject *rootObject() const { return root; }
00113
00115 QObject *object() const { return obj; }
00116
00118 QWidget *widget() const
00119 {
00120 QObject *w = obj;
00121 return (w && w->isWidgetType()) ? static_cast<QWidget *>(w) : 0;
00122 }
00123
00125 const JSSecurityPolicy *securityPolicy() const { return policy; }
00126
00131 void setSecurityPolicy( const JSSecurityPolicy *sp );
00132
00134 virtual KJS::Value get( KJS::ExecState *exec, const KJS::Identifier &p ) const;
00135
00137 virtual void put( KJS::ExecState *exec, const KJS::Identifier &p,
00138 const KJS::Value &v, int attr = KJS::None );
00139
00141 virtual KJS::UString toString( KJS::ExecState *exec ) const;
00142
00153 virtual void addBindings( KJS::ExecState *exec, KJS::Object &object );
00154
00155 protected:
00156 void addBindingsClass( KJS::ExecState *exec, KJS::Object &object );
00157
00161 void addBindingsEnum( KJS::ExecState *exec, KJS::Object &object );
00162
00166 void addBindingsSlots( KJS::ExecState *exec, KJS::Object &object );
00167
00168
00169 private:
00170 bool isAllowed( KJS::Interpreter *js ) const;
00171
00172 void addSlotBinding( const QCString &name, KJS::ExecState *exec, KJS::Object &object );
00173
00174 private:
00175 KJSEmbedPart *jspart;
00176 KJS::Interpreter *js;
00177 QGuardedPtr<QObject> obj;
00178 QGuardedPtr<QObject> root;
00179 const JSSecurityPolicy *policy;
00180 class JSObjectProxyPrivate *d;
00181 friend class Bindings::JSObjectProxyImp;
00182 };
00183
00184 }
00185
00186 #endif
00187
00188
00189
00190