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
00028 #include <kjs/object.h>
00029 #include <kjsembed/jsbinding.h>
00030
00031 namespace KJS { class Interpreter; };
00032
00033 namespace KJSEmbed {
00034
00035 namespace Bindings { class JSObjectProxyImp; };
00036
00037 class JSSecurityPolicy;
00038 class JSObjectProxyPrivate;
00039
00094 class JSObjectProxy : public KJS::ObjectImp
00095 {
00096 public:
00101 JSObjectProxy( KJS::Interpreter *js, QObject *target );
00102
00108 JSObjectProxy( KJS::Interpreter *js, QObject *target, QObject *root );
00109
00116 JSObjectProxy( KJS::Interpreter *js, QObject *target,
00117 QObject *root, const JSSecurityPolicy *sp );
00118
00119 ~JSObjectProxy() {}
00120
00127 virtual void addBindings( KJS::ExecState *state, KJS::Object &object );
00128
00129 KJS::Object createSubProxy( QObject *target, KJS::ExecState *state=0 ) const;
00130
00132 KJS::Interpreter *jscript() const { return js; }
00133
00135 QObject *rootObject() const { return root; }
00136
00138 QObject *object() const { return obj; }
00139
00141 const JSSecurityPolicy *securityPolicy() const { return policy; }
00142
00147 void setSecurityPolicy( const JSSecurityPolicy *sp );
00148
00150 virtual KJS::Value get( KJS::ExecState *state, const KJS::UString &p ) const;
00151
00153 virtual void put( KJS::ExecState *state, const KJS::UString &p,
00154 const KJS::Value &v, int attr = KJS::None );
00155
00157 virtual KJS::UString toString( KJS::ExecState *exec ) const;
00158
00159 int findSignature( const QString &sig ) const;
00160
00161 private:
00162 bool isAllowed( KJS::Interpreter *js ) const;
00163
00164 private:
00165 KJS::Interpreter *js;
00166 QGuardedPtr<QObject> obj;
00167 QGuardedPtr<QObject> root;
00168 const JSSecurityPolicy *policy;
00169 class JSObjectProxyPrivate *d;
00170 friend class Bindings::JSObjectProxyImp;
00171 };
00172
00173 };
00174
00175 #endif
00176
00177
00178
00179