1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
// -*- c++ -*-
/*
* Copyright (C) 2001-2003, Richard J. Moore <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KJSEMBEDJSOBJECTPROXYIMP_H
#define KJSEMBEDJSOBJECTPROXYIMP_H
#include <tqguardedptr.h>
#include <kjs/interpreter.h>
#include <kjsembed/jsproxy_imp.h>
#include <kjsembed/jsfactory.h>
namespace KJSEmbed {
namespace Bindings {
/**
* Implements the JS methods of KJSEmbed::ObjectProxy.
*
* @author Richard Moore, [email protected]
* @version $Id$
*/
class JSObjectProxyImp : public JSProxyImp
{
public:
/** Identifiers for the method implementations available. */
enum MethodId {
/** Indicates an error, usually an supported signature. */
MethodInternalError,
/** Meta info about the object. */
/* { */
MethodProps,
MethodIsWidgetType, MethodClassName, MethodSuperClassName,
/* } */
/** Methods for accessing the object tree. */
/* { */
MethodChildren, MethodParent, MethodChild, MethodChildCount,
/* } */
/** Fast slot signature. */
MethodSlot,
/** Custom slot signature. */
MethodCustomSlot,
/** Connections. */
/* { */
MethodSignals, MethodSlots,
MethodConnect, MethodDisconnect,
/* } */
/** DOM methods. */
/* { */
MethodGetParentNode, MethodGetElementById, MethodGetElementsByTagName,
MethodHasAttribute, MethodGetAttribute, MethodSetAttribute,
/* } */
/** Custom method. */
MethodCustom = 0x1000
};
/**
* Adds the tree bindings to the proxy.
* <ul>
* <li>parent()
* <li>childAt(int index)
* <li>childCount()
* <li>findChild(string name)
* <li>child(string name)
* <li>child(int index)
* </ul>
*/
static void addBindingsTree( KJS::ExecState *exec, KJS::Object &object, JSObjectProxy *proxy );
/**
* Adds the DOM bindings to the proxy.
* <ul>
* <li>getElementById(name)
* <li>hasAttribute(name)
* <li>getAttribute(name)
* <li>setAttribute(name,value)
* </ul>
*/
static void addBindingsDOM( KJS::ExecState *exec, KJS::Object &object, JSObjectProxy *proxy );
/**
* Adds the connect bindings to the proxy.
* <ul>
* <li>connect(signal,receiver,slot)
* <li>disconnect(signal,receiver,slot)
* </ul>
*/
static void addBindingsConnect( KJS::ExecState *exec, KJS::Object &object, JSObjectProxy *proxy );
JSObjectProxyImp( KJS::ExecState *exec,
int id, JSObjectProxy *parent );
JSObjectProxyImp( KJS::ExecState *exec,
int id, const TQCString &name, JSObjectProxy *parent );
JSObjectProxyImp( KJS::ExecState *exec,
int id, int sigid, const TQCString &name, JSObjectProxy *parent );
JSObjectProxyImp( KJS::ExecState *exec,
int id, const char *ret, int sig, const TQCString &name, JSObjectProxy *parent );
~JSObjectProxyImp() {}
/** Implements the object tree interface. */
/*{*/
KJS::Value childAt( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Value findChild( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Value children( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Value properties( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
/*}*/
/** Implements the DOM interface. */
/*{*/
KJS::Value getParentNode( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Value getElementById( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Value getElementsByTagName( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Value hasAttribute( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Value getAttribute( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Value setAttribute( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
/*}*/
/** Calls the slots. */
KJS::Value callSlot( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
/** Implements signal-slot support. */
/*{*/
KJS::Value signalz( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Value slotz( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Boolean connect( KJS::ExecState *exec, const KJS::Object &self, const KJS::List &args );
KJS::Boolean disconnect( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
KJS::Boolean connect( TQObject *sender, const char *sig, const KJS::Object &recv, const TQString &dest );
/*}*/
virtual bool implementsCall() const { return true; }
virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
const char *returnType() const { return rettype; }
const char *slotName() const { return slotname; }
int signature() const { return sigid; }
JSObjectProxy *objectProxy() const { return proxy; }
protected:
/** Calls a slot that has a custom signature. */
KJS::Value callCustomSlot( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
private:
int id;
TQCString rettype; // return type
int sigid; // signatureid
int slotid;
TQCString slotname;
JSObjectProxy *proxy;
TQGuardedPtr<TQObject> obj;
class JSObjectProxyImpPrivate *d;
};
} // namespace KJSEmbed::Bindings
} // namespace KJSEmbed
#endif // KJSEMBEDJSOBJECTPROXYIMP_H
// Local Variables:
// c-basic-offset: 4
// End:
|