1 /* This file is part of the KDE libraries
2 Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
3 Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
4 Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
5 Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21 */
22
23 #ifndef BINDING_SUPPORT_H
24 #define BINDING_SUPPORT_H
25
26 #include <QDate>
27 #include <QStringList>
28
29 #include <kjsembed/kjseglobal.h>
30 #include <kjsembed/pointer.h>
31 #include <kjs/object.h>
32
33 #define KJS_BINDING( NAME ) \
34 class NAME \
35 { \
36 public: \
37 static const KJSEmbed::Method p_methods[]; \
38 static const KJSEmbed::Method p_statics[]; \
39 static const KJSEmbed::Enumerator p_enums[]; \
40 static const KJSEmbed::Constructor p_constructor; \
41 static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
42 static const KJSEmbed::Enumerator *enums() { return p_enums;} \
43 static const KJSEmbed::Method *methods() { return p_methods;} \
44 static const KJSEmbed::Method *statics() { return p_statics;} \
45 static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
46 static const KJS::JSObject *construct(KJS::ExecState *exec, const KJS::List &args)\
47 { return (*p_constructor.construct)(exec,args); } \
48 };
49
50 #define KJSO_BINDING( NAME, TYPE, BASENAME ) \
51 class KJSEMBED_EXPORT NAME : public BASENAME \
52 { \
53 public: \
54 NAME(KJS::ExecState *exec, TYPE * obj); \
55 static const KJSEmbed::Method p_methods[]; \
56 static const KJSEmbed::Method p_statics[]; \
57 static const KJSEmbed::Enumerator p_enums[]; \
58 static const KJSEmbed::Constructor p_constructor; \
59 static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
60 static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
61 static const KJSEmbed::Enumerator *enums() { return p_enums;} \
62 static const KJSEmbed::Method *methods() { return p_methods;} \
63 static const KJSEmbed::Method *statics() { return p_statics;} \
64 static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
65 };
66
67 #define KJSO_BINDING_NOEXP( NAME, TYPE, BASENAME ) \
68 class NAME : public BASENAME \
69 { \
70 public: \
71 NAME(KJS::ExecState *exec, TYPE * obj); \
72 static const KJSEmbed::Method p_methods[]; \
73 static const KJSEmbed::Method p_statics[]; \
74 static const KJSEmbed::Enumerator p_enums[]; \
75 static const KJSEmbed::Constructor p_constructor; \
76 static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
77 static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
78 static const KJSEmbed::Enumerator *enums() { return p_enums;} \
79 static const KJSEmbed::Method *methods() { return p_methods;} \
80 static const KJSEmbed::Method *statics() { return p_statics;} \
81 static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
82 };
83
84 #define KJSO_VALUE_BINDING( NAME, TYPE, BASENAME ) \
85 class KJSEMBED_EXPORT NAME : public BASENAME \
86 { \
87 public: \
88 NAME(KJS::ExecState *exec, const TYPE & val ); \
89 NAME(KJS::ExecState *exec, const char *typeName ); \
90 static const KJSEmbed::Method p_methods[]; \
91 static const KJSEmbed::Method p_statics[]; \
92 static const KJSEmbed::Enumerator p_enums[]; \
93 static const KJSEmbed::Constructor p_constructor; \
94 static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
95 static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
96 static const KJSEmbed::Enumerator *enums() { return p_enums;} \
97 static const KJSEmbed::Method *methods() { return p_methods;} \
98 static const KJSEmbed::Method *statics() { return p_statics;} \
99 static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
100 };
101
102 #define KJSO_START_BINDING_CTOR( NAME, TYPE, BASENAME ) \
103 NAME::NAME(KJS::ExecState *exec, TYPE * obj) \
104 : BASENAME( exec, obj ) \
105 { \
106 StaticBinding::publish( exec, this, NAME::methods() );
107
108 #define KJSO_END_BINDING_CTOR \
109 }
110
111 #define KJSO_SIMPLE_BINDING_CTOR( NAME, TYPE, BASENAME ) \
112 NAME::NAME(KJS::ExecState *exec, TYPE * obj) \
113 : BASENAME( exec, obj ) \
114 { \
115 StaticBinding::publish( exec, this, NAME::methods() ); \
116 }
117
118 #define KJSV_SIMPLE_BINDING_CTOR( NAME, JSNAME, TYPE, BASENAME ) \
119 NAME::NAME(KJS::ExecState *exec, const TYPE & value) \
120 : BASENAME( exec, #JSNAME , value ) \
121 { \
122 StaticBinding::publish( exec, this, NAME::methods() ); \
123 }
124
125 #define START_METHOD_LUT( TYPE ) \
126 const Method TYPE::p_methods[] = \
127 {
128
129 #define START_STATIC_METHOD_LUT( TYPE ) \
130 const Method TYPE::p_statics[] = \
131 {
132
133 #define END_METHOD_LUT \
134 ,{nullptr, 0, 0, nullptr }\
135 };
136
137 #define START_ENUM_LUT( TYPE) \
138 const Enumerator TYPE::p_enums[] =\
139 {
140
141 #define END_ENUM_LUT \
142 ,{nullptr, 0 }\
143 };
144
145 #define NO_ENUMS( TYPE ) \
146 const Enumerator TYPE::p_enums[] = {{nullptr, 0 }};
147
148 #define NO_METHODS( TYPE )\
149 const Method TYPE::p_methods[] = { {nullptr, 0, 0, nullptr } };
150
151 #define NO_STATICS( TYPE )\
152 const Method TYPE::p_statics[] = { {nullptr, 0, 0, nullptr } };
153
154 #define START_CTOR( TYPE, JSNAME, ARGS )\
155 const Constructor TYPE::p_constructor = \
156 { \
157 #JSNAME, ARGS, KJS::DontDelete|KJS::ReadOnly, nullptr, &TYPE::ctorMethod, p_statics, p_enums, p_methods };\
158 KJS::JSObject *TYPE::ctorMethod( KJS::ExecState *exec, const KJS::List &args )\
159 {\
160 Q_UNUSED(exec);\
161 Q_UNUSED(args);
162
163 #define END_CTOR \
164 }
165
166 #define KJSO_START_CTOR( TYPE, JSNAME, ARGS )\
167 const Constructor TYPE::p_constructor = \
168 { \
169 #JSNAME, ARGS, KJS::DontDelete|KJS::ReadOnly, &TYPE::bindMethod, &TYPE::ctorMethod, p_statics, p_enums, p_methods };\
170 KJS::JSObject *TYPE::ctorMethod( KJS::ExecState *exec, const KJS::List &args )\
171 {\
172 Q_UNUSED(exec);\
173 Q_UNUSED(args);
174
175 #define KJSO_END_CTOR \
176 }
177
178 #define KJSO_START_BIND( NAME, TYPE )\
179 KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
180 {\
181 Q_UNUSED(exec);\
182 Q_UNUSED(ptrObj); \
183
184 #define KJSO_END_BIND \
185 }
186
187 #define KJSO_QOBJECT_START_BIND( NAME, TYPE )\
188 KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
189 {\
190 Q_UNUSED(exec);\
191 QObject* qobj = pointer_cast<QObject>(&ptrObj); \
192 if (! qobj ) \
193 return nullptr; \
194 TYPE* object = qobject_cast<TYPE*>(qobj); \
195 if (! object ) \
196 return nullptr; \
197
198 #define KJSO_QOBJECT_END_BIND \
199 }
200
201 #define KJSO_QOBJECT_BIND( NAME, TYPE )\
202 KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
203 {\
204 Q_UNUSED(exec);\
205 QObject* qobj = pointer_cast<QObject>(&ptrObj); \
206 if (! qobj ) \
207 return nullptr; \
208 TYPE* object = qobject_cast<TYPE*>(qobj); \
209 if (! object ) \
210 return nullptr; \
211 return new NAME(exec, object); \
212 }
213
214 #define KJSO_VALUE_START_BIND( NAME, TYPE )\
215 KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
216 {\
217 Q_UNUSED(exec);\
218 TYPE* object = pointer_cast<TYPE>(&ptrObj); \
219 if (! object ) \
220 return nullptr; \
221
222 #define KJSO_VALUE_END_BIND \
223 }
224
225 #define KJSO_VALUE_BIND( NAME, TYPE )\
226 KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
227 {\
228 Q_UNUSED(exec);\
229 TYPE* object = pointer_cast<TYPE>(&ptrObj); \
230 if (! object ) \
231 return nullptr; \
232 return new NAME(exec, *object); \
233 }
234
235 namespace KJS
236 {
throwError(ExecState * e,ErrorType t,const QString & m)237 inline JSObject *throwError(ExecState *e, ErrorType t, const QString &m)
238 {
239 return throwError(e, t, KJSEmbed::toUString(m));
240 }
241 }
242
243 namespace KJSEmbed
244 {
245 class KJSEMBED_EXPORT ProxyBinding : public KJS::JSObject
246 {
247 public:
248 ProxyBinding(KJS::ExecState *exec);
~ProxyBinding()249 ~ProxyBinding() override {}
250
implementsCall()251 bool implementsCall() const override
252 {
253 return true;
254 }
implementsConstruct()255 bool implementsConstruct() const override
256 {
257 return true;
258 }
259 };
260
261 /**
262 * This will extract a binding implementation from a KJS::JSValue
263 * @code
264 * KJSEmbed ObjectBindingImp *imp = extractBindingImp<ObjectBindingImp>(exec,val);
265 * if( imp )
266 * qDebug("it worked");
267 * else
268 * qDebug("it failed");
269 * @endcode
270 */
271 template <typename T>
extractBindingImp(KJS::ExecState * exec,KJS::JSValue * val)272 T *extractBindingImp(KJS::ExecState *exec, KJS::JSValue *val)
273 {
274 return dynamic_cast<T *>(val->toObject(exec));
275 }
276
277 /**
278 * This is just a helper function similar to the one above, only it takes a KJS::JSObject
279 */
280 template <typename T>
extractBindingImp(KJS::JSObject * obj)281 T *extractBindingImp(KJS::JSObject *obj)
282 {
283 return dynamic_cast<T *>(obj);
284 }
285
286 /**
287 * Method callback signature.
288 * @param exec The execution state.
289 * @param object The current object that the method is working on (equivalent of "this")
290 * @param args A KJS::List of KJS::JSValue objects that represents the arguments that where
291 * passed in from the javascript function signature.
292 */
293 typedef KJS::JSValue *(*callMethod)(KJS::ExecState *, KJS::JSObject *, const KJS::List &);
294
295 /**
296 * Method structure
297 */
298 struct KJSEMBED_EXPORT Method {
299 /**
300 * Method name as will appear in javascript
301 */
302 const char *name;
303 /**
304 * Number of arguments.
305 */
306 const int argc;
307 /**
308 * Flags for the member properties
309 */
310 const int flags;
311 /**
312 * The callback for the method.
313 */
314 const callMethod call;
315 };
316
317 /**
318 * Enumerator structure
319 */
320 struct KJSEMBED_EXPORT Enumerator {
321 /**
322 * Method name as will appear in javascript
323 */
324 const char *name;
325 /**
326 * Integer value.
327 */
328 const unsigned int value;
329 };
330
331 /**
332 * Bind signature
333 * @param exec the execution context
334 * @param ptr A PointerBase that points to a Pointer object that contains
335 * a pointer to the object to provide a javascript binding for.
336 */
337 typedef KJS::JSObject *(*callBind)(KJS::ExecState *, PointerBase &);
338
339 /**
340 * Constructor signature
341 * @param exec the execution context
342 * @param args A KJS::List of KJS::JSValue objects that represents the arguments that where
343 * passed in from the javascript function signature.
344 */
345 typedef KJS::JSObject *(*callConstructor)(KJS::ExecState *, const KJS::List &);
346
347 struct KJSEMBED_EXPORT Constructor {
348 /**
349 * The constructor name as it will appear in Javascript. This will be the objects
350 * name as far as Javascript is concerned.
351 */
352 const char *name;
353 /**
354 * Number of arguments.
355 */
356 const int argc;
357 /**
358 * Flags for the member properties
359 */
360 const int flags;
361 /**
362 * The callback for the constructor.
363 */
364 const callBind bind;
365 /**
366 * The callback for the constructor.
367 */
368 const callConstructor construct;
369 /**
370 * Static methods on the object.
371 */
372 const Method *staticMethods;
373 /**
374 * Enumerators for the object
375 */
376 const Enumerator *enumerators;
377 /**
378 * Member methods for the object
379 */
380 const Method *methods;
381 };
382
383 /**
384 * Extracts a QString from an argument list. If the argument is not present, or is not convertable to a string
385 * the defaultValue is returned.
386 */
387 QString KJSEMBED_EXPORT extractQString(KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue = QString());
388
389 /**
390 * Extract a QString from a value. If the value cannot convert to a string the defaultValue is returned.
391 */
392 QString KJSEMBED_EXPORT extractQString(KJS::ExecState *exec, KJS::JSValue *value, const QString defaultValue = QString());
393
394 /**
395 * Create a new KJS::JSValue with the value of the QString
396 */
397 KJS::JSValue *createQString(KJS::ExecState *exec, const QString &value);
398
399 /**
400 * Extracts a QByteArray from an argument list. If the argument is not present, or is not convertable to a string
401 * the defaultValue is returned.
402 */
403 QByteArray KJSEMBED_EXPORT extractQByteArray(KJS::ExecState *exec, const KJS::List &args, int idx, const QByteArray &defaultValue = QByteArray());
404
405 /**
406 * Extract a QString from a value. If the value cannot convert to a string the defaultValue is returned.
407 */
408 QByteArray KJSEMBED_EXPORT extractQByteArray(KJS::ExecState *exec, KJS::JSValue *value, const QByteArray &defaultValue = QByteArray());
409
410 /**
411 * Create a new KJS::JSValue with the value of the QString
412 */
413 KJS::JSValue *createQByteArray(KJS::ExecState *exec, const QByteArray &value);
414
415 template<typename T>
416 inline T KJSEMBED_EXPORT extractString(KJS::ExecState *exec, KJS::JSValue *value, T defaultValue = T())
417 {
418 if (!value || !value->isString()) {
419 return defaultValue;
420 }
421
422 return (T)(value->toString(exec).ascii());
423 }
424
425 template<typename T>
426 inline T KJSEMBED_EXPORT extractString(KJS::ExecState *exec, const KJS::List &args, int idx, T defaultValue = T())
427 {
428 if (args.size() >= idx) {
429 return extractString<T>(exec, args[idx], defaultValue);
430 } else {
431 return defaultValue;
432 }
433 }
434
435 /**
436 * Extract a number from a value. If the value cannot convert to an integer or is not present defaultValue is returned
437 */
438 template<typename T>
439 inline T KJSEMBED_EXPORT extractNumber(KJS::ExecState *exec, KJS::JSValue *value, T defaultValue = T(0))
440 {
441 if (!value || !value->isNumber()) {
442 return defaultValue;
443 }
444
445 return static_cast<T>(value->toNumber(exec));
446 }
447
448 /**
449 * Extracts a number from an arguments list. If the argument is not present, or is not convertable to a number
450 * the defaultValue is returned.
451 */
452 template<typename T>
453 inline T KJSEMBED_EXPORT extractNumber(KJS::ExecState *exec, const KJS::List &args, int idx, T defaultValue = T(0))
454 {
455 if (args.size() >= idx) {
456 return extractNumber<T>(exec, args[idx], defaultValue);
457 } else {
458 return defaultValue;
459 }
460 }
461
462 /**
463 * Extract an integer from a value. If the value cannot convert to an integer or is not present defaultValue is returned
464 */
465 template<typename T>
extractInteger(KJS::ExecState * exec,KJS::JSValue * value,T defaultValue)466 inline T KJSEMBED_EXPORT extractInteger(KJS::ExecState *exec, KJS::JSValue *value, T defaultValue)
467 {
468 if (!value || !value->isNumber()) {
469 return defaultValue;
470 }
471
472 // deal with MSVC annoyances
473 #if COMPILER(MSVC) || __GNUC__ == 3
474 return static_cast<T>(static_cast<int>(value->toInteger(exec)));
475 #else
476 return static_cast<T>(value->toInteger(exec));
477 #endif
478 }
479
480 // extractInteger specialization
481 template<>
482 inline qint32 KJSEMBED_EXPORT extractInteger<qint32>(KJS::ExecState *exec, KJS::JSValue *value, qint32 defaultValue)
483 {
484 if (!value || !value->isNumber()) {
485 return defaultValue;
486 }
487
488 return static_cast<qint32>(value->toInt32(exec));
489 }
490
491 // extractInteger specialization
492 template<>
493 inline quint32 KJSEMBED_EXPORT extractInteger<quint32>(KJS::ExecState *exec, KJS::JSValue *value, quint32 defaultValue)
494 {
495 if (!value || !value->isNumber()) {
496 return defaultValue;
497 }
498
499 return static_cast<quint32>(value->toUInt32(exec));
500 }
501
502 // extractInteger specialization
503 template<>
504 inline quint16 KJSEMBED_EXPORT extractInteger<quint16>(KJS::ExecState *exec, KJS::JSValue *value, quint16 defaultValue)
505 {
506 if (!value || !value->isNumber()) {
507 return defaultValue;
508 }
509
510 return static_cast<quint16>(value->toUInt16(exec));
511 }
512
513 /**
514 * Extracts an integer from an arguments list. If the argument is not present, or is not convertable to a number
515 * the defaultValue is returned.
516 */
517 template<typename T>
518 inline T KJSEMBED_EXPORT extractInteger(KJS::ExecState *exec, const KJS::List &args, int idx, T defaultValue = T(0))
519 {
520 if (args.size() >= idx) {
521 return extractInteger<T>(exec, args[idx], defaultValue);
522 } else {
523 return defaultValue;
524 }
525 }
526
527 /**
528 * Extracts an integer from an argument list. If the argument is not present, or is not convertable to an integer
529 * the defaultValue is returned.
530 */
531 int KJSEMBED_EXPORT extractInt(KJS::ExecState *exec, const KJS::List &args, int idx, int defaultValue = 0);
532 /**
533 * Extract an integer from a value. If the value cannot convert to an integer the defaultValue is returned.
534 */
535 int KJSEMBED_EXPORT extractInt(KJS::ExecState *exec, KJS::JSValue *value, int defaultValue = 0);
536 /**
537 * Create a new KJS::JSValue with the value of the integer.
538 */
539 KJS::JSValue *createInt(KJS::ExecState *exec, int value);
540
541 /**
542 * Extracts a double from an argument list. If the argument is not present, or is not convertable to a double
543 * the defaultValue is returned.
544 */
545 double KJSEMBED_EXPORT extractDouble(KJS::ExecState *exec, const KJS::List &args, int idx, double defaultValue = 0);
546 /**
547 * Extract a double from a value. If the value cannot convert to a double the defaultValue is returned.
548 */
549 double KJSEMBED_EXPORT extractDouble(KJS::ExecState *exec, KJS::JSValue *value, double defaultValue = 0);
550 /**
551 * Create a new KJS::JSValue with the value of the double.
552 */
553 KJS::JSValue *createDouble(KJS::ExecState *exec, double value);
554
555 /**
556 * Extracts a float from an argument list. If the argument is not present, or is not convertable to a float
557 * the defaultValue is returned.
558 */
559 float KJSEMBED_EXPORT extractFloat(KJS::ExecState *exec, const KJS::List &args, int idx, float defaultValue = 0);
560 /**
561 * Extract a float from a value. If the value cannot convert to a float the defaultValue is returned.
562 */
563 float KJSEMBED_EXPORT extractFloat(KJS::ExecState *exec, KJS::JSValue *value, float defaultValue = 0);
564 /**
565 * Create a new KJS::JSValue with the value of the float.
566 */
567 KJS::JSValue *createFloat(KJS::ExecState *exec, float value);
568
569 /**
570 * Extracts a bool from an argument list. If the argument is not present, or is not convertable to a bool
571 * the defaultValue is returned.
572 */
573 bool KJSEMBED_EXPORT extractBool(KJS::ExecState *exec, const KJS::List &args, int idx, bool defaultValue = false);
574 /**
575 * Extract a bool from a value. If the value cannot convert to a bool the defaultValue is returned.
576 */
577 bool extractBool(KJS::ExecState *exec, KJS::JSValue *value, bool defaultValue = false);
578 /**
579 * Create a new KJS::JSValue with the value of the bool.
580 */
581 KJS::JSValue *createBool(KJS::ExecState *exec, bool value);
582
583 /**
584 * Extracts a QDateTime from an argument list. If the argument is not present, or is not convertable to a QDateTime
585 * the defaultValue is returned.
586 */
587 QDateTime KJSEMBED_EXPORT extractQDateTime(KJS::ExecState *exec, const KJS::List &args, int idx, const QDateTime &defaultValue = QDateTime());
588 /**
589 * Extract a bool from a value. If the value cannot convert to a QDateTime the defaultValue is returned.
590 */
591 QDateTime KJSEMBED_EXPORT extractQDateTime(KJS::ExecState *exec, KJS::JSValue *value, const QDateTime &defaultValue = QDateTime());
592 /**
593 * Create a new KJS::JSValue with the value of the QDateTime.
594 */
595 KJS::JSValue *createQDateTime(KJS::ExecState *exec, const QDateTime &value);
596
597 /**
598 * Extracts a QDate from an argument list. If the argument is not present, or is not convertable to a QDate
599 * the defaultValue is returned.
600 */
601 QDate KJSEMBED_EXPORT extractQDate(KJS::ExecState *exec, const KJS::List &args, int idx, const QDate &defaultValue = QDate());
602 /**
603 * Extract a QDate from a value. If the value cannot convert to a QDate the defaultValue is returned.
604 */
605 QDate KJSEMBED_EXPORT extractQDate(KJS::ExecState *exec, KJS::JSValue *value, const QDate &defaultValue = QDate());
606 /**
607 * Create a new KJS::JSValue with the value of the QDate.
608 */
609 KJS::JSValue *createQDate(KJS::ExecState *exec, const QDate &value);
610
611 /**
612 * Extracts a QTime from an argument list. If the argument is not present, or is not convertable to a QTime
613 * the defaultValue is returned.
614 */
615 QTime KJSEMBED_EXPORT extractQTime(KJS::ExecState *exec, const KJS::List &args, int idx, const QTime &defaultValue = QTime());
616 /**
617 * Extract a QTime from a value. If the value cannot convert to a QTime the defaultValue is returned.
618 */
619 QTime KJSEMBED_EXPORT extractQTime(KJS::ExecState *exec, KJS::JSValue *value, const QTime &defaultValue = QTime());
620 /**
621 * Create a new KJS::JSValue with the value of the QTime.
622 */
623 KJS::JSValue *createQTime(KJS::ExecState *exec, const QTime &value);
624
625 /**
626 * Extracts a QStringList from an argument list. If the argument is not present, or is not convertable to a QStringList
627 * the defaultValue is returned.
628 */
629 QStringList KJSEMBED_EXPORT extractQStringList(KJS::ExecState *exec, const KJS::List &args, int idx, const QStringList &defaultValue = QStringList());
630 /**
631 * Extract a QStringList from a value. If the value cannot convert to a QStringList the defaultValue is returned.
632 */
633 QStringList KJSEMBED_EXPORT extractQStringList(KJS::ExecState *exec, KJS::JSValue *value, const QStringList &defaultValue = QStringList());
634 /**
635 * Create a new KJS::JSValue with the value of the QStringList.
636 */
637 KJS::JSValue *createQStringList(KJS::ExecState *exec, const QStringList &value);
638
639 }
640
641 #endif
642