File indexing completed on 2024-11-03 09:57:54

0001 /* This file is part of the KDE libraries
0002     Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
0003     Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
0004     Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
0005     Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Library General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Library General Public License for more details.
0016 
0017     You should have received a copy of the GNU Library General Public License
0018     along with this library; see the file COPYING.LIB.  If not, write to
0019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020     Boston, MA 02110-1301, USA.
0021 */
0022 
0023 #ifndef BINDING_SUPPORT_H
0024 #define BINDING_SUPPORT_H
0025 
0026 #include <QDate>
0027 #include <QStringList>
0028 
0029 #include <kjsembed/kjseglobal.h>
0030 #include <kjsembed/pointer.h>
0031 #include <kjs/object.h>
0032 
0033 #define KJS_BINDING( NAME ) \
0034     class NAME \
0035     { \
0036     public: \
0037         static const KJSEmbed::Method p_methods[]; \
0038         static const KJSEmbed::Method p_statics[]; \
0039         static const KJSEmbed::Enumerator p_enums[]; \
0040         static const KJSEmbed::Constructor p_constructor; \
0041         static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
0042         static const KJSEmbed::Enumerator *enums() { return p_enums;} \
0043         static const KJSEmbed::Method *methods() { return p_methods;} \
0044         static const KJSEmbed::Method *statics() { return p_statics;} \
0045         static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
0046         static const KJS::JSObject *construct(KJS::ExecState *exec, const KJS::List &args)\
0047         { return (*p_constructor.construct)(exec,args); } \
0048     };
0049 
0050 #define KJSO_BINDING( NAME, TYPE, BASENAME ) \
0051     class KJSEMBED_EXPORT NAME : public BASENAME \
0052     { \
0053     public: \
0054         NAME(KJS::ExecState *exec, TYPE * obj); \
0055         static const KJSEmbed::Method p_methods[]; \
0056         static const KJSEmbed::Method p_statics[]; \
0057         static const KJSEmbed::Enumerator p_enums[]; \
0058         static const KJSEmbed::Constructor p_constructor; \
0059         static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
0060         static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
0061         static const KJSEmbed::Enumerator *enums() { return p_enums;} \
0062         static const KJSEmbed::Method *methods() { return p_methods;} \
0063         static const KJSEmbed::Method *statics() { return p_statics;} \
0064         static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
0065     };
0066 
0067 #define KJSO_BINDING_NOEXP( NAME, TYPE, BASENAME ) \
0068     class NAME : public BASENAME \
0069     { \
0070     public: \
0071         NAME(KJS::ExecState *exec, TYPE * obj); \
0072         static const KJSEmbed::Method p_methods[]; \
0073         static const KJSEmbed::Method p_statics[]; \
0074         static const KJSEmbed::Enumerator p_enums[]; \
0075         static const KJSEmbed::Constructor p_constructor; \
0076         static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
0077         static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
0078         static const KJSEmbed::Enumerator *enums() { return p_enums;} \
0079         static const KJSEmbed::Method *methods() { return p_methods;} \
0080         static const KJSEmbed::Method *statics() { return p_statics;} \
0081         static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
0082     };
0083 
0084 #define KJSO_VALUE_BINDING( NAME, TYPE, BASENAME ) \
0085     class KJSEMBED_EXPORT NAME : public BASENAME \
0086     { \
0087     public: \
0088         NAME(KJS::ExecState *exec, const TYPE & val ); \
0089         NAME(KJS::ExecState *exec, const char *typeName ); \
0090         static const KJSEmbed::Method p_methods[]; \
0091         static const KJSEmbed::Method p_statics[]; \
0092         static const KJSEmbed::Enumerator p_enums[]; \
0093         static const KJSEmbed::Constructor p_constructor; \
0094         static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
0095         static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
0096         static const KJSEmbed::Enumerator *enums() { return p_enums;} \
0097         static const KJSEmbed::Method *methods() { return p_methods;} \
0098         static const KJSEmbed::Method *statics() { return p_statics;} \
0099         static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
0100     };
0101 
0102 #define KJSO_START_BINDING_CTOR( NAME, TYPE, BASENAME ) \
0103     NAME::NAME(KJS::ExecState *exec, TYPE * obj) \
0104         : BASENAME( exec, obj ) \
0105     { \
0106         StaticBinding::publish( exec, this, NAME::methods() );
0107 
0108 #define KJSO_END_BINDING_CTOR \
0109     }
0110 
0111 #define KJSO_SIMPLE_BINDING_CTOR( NAME, TYPE, BASENAME ) \
0112     NAME::NAME(KJS::ExecState *exec, TYPE * obj) \
0113         : BASENAME( exec, obj ) \
0114     { \
0115         StaticBinding::publish( exec, this, NAME::methods() ); \
0116     }
0117 
0118 #define KJSV_SIMPLE_BINDING_CTOR( NAME, JSNAME, TYPE, BASENAME )        \
0119     NAME::NAME(KJS::ExecState *exec, const TYPE & value) \
0120         : BASENAME( exec, #JSNAME , value )                    \
0121     { \
0122         StaticBinding::publish( exec, this, NAME::methods() ); \
0123     }
0124 
0125 #define START_METHOD_LUT( TYPE ) \
0126     const Method TYPE::p_methods[] = \
0127                                      {
0128 
0129 #define START_STATIC_METHOD_LUT( TYPE ) \
0130     const Method TYPE::p_statics[] = \
0131                                      {
0132 
0133 #define END_METHOD_LUT \
0134     ,{nullptr, 0, 0, nullptr }\
0135     };
0136 
0137 #define START_ENUM_LUT( TYPE) \
0138     const Enumerator TYPE::p_enums[] =\
0139                                       {
0140 
0141 #define END_ENUM_LUT \
0142     ,{nullptr, 0 }\
0143     };
0144 
0145 #define NO_ENUMS( TYPE ) \
0146     const Enumerator TYPE::p_enums[] = {{nullptr, 0 }};
0147 
0148 #define NO_METHODS( TYPE )\
0149     const Method TYPE::p_methods[] = { {nullptr, 0, 0, nullptr } };
0150 
0151 #define NO_STATICS( TYPE )\
0152     const Method TYPE::p_statics[] = { {nullptr, 0, 0, nullptr } };
0153 
0154 #define START_CTOR( TYPE, JSNAME, ARGS )\
0155     const Constructor TYPE::p_constructor = \
0156                                             { \
0157                                               #JSNAME, ARGS, KJS::DontDelete|KJS::ReadOnly, nullptr, &TYPE::ctorMethod, p_statics, p_enums, p_methods };\
0158     KJS::JSObject *TYPE::ctorMethod( KJS::ExecState *exec, const KJS::List &args )\
0159     {\
0160         Q_UNUSED(exec);\
0161         Q_UNUSED(args);
0162 
0163 #define END_CTOR \
0164     }
0165 
0166 #define KJSO_START_CTOR( TYPE, JSNAME, ARGS )\
0167     const Constructor TYPE::p_constructor = \
0168                                             { \
0169                                               #JSNAME, ARGS, KJS::DontDelete|KJS::ReadOnly, &TYPE::bindMethod, &TYPE::ctorMethod, p_statics, p_enums, p_methods };\
0170     KJS::JSObject *TYPE::ctorMethod( KJS::ExecState *exec, const KJS::List &args )\
0171     {\
0172         Q_UNUSED(exec);\
0173         Q_UNUSED(args);
0174 
0175 #define KJSO_END_CTOR \
0176     }
0177 
0178 #define KJSO_START_BIND( NAME, TYPE )\
0179     KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
0180     {\
0181         Q_UNUSED(exec);\
0182         Q_UNUSED(ptrObj); \
0183          
0184 #define KJSO_END_BIND \
0185     }
0186 
0187 #define KJSO_QOBJECT_START_BIND( NAME, TYPE )\
0188     KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
0189     {\
0190         Q_UNUSED(exec);\
0191         QObject* qobj = pointer_cast<QObject>(&ptrObj); \
0192         if (! qobj ) \
0193             return nullptr; \
0194         TYPE* object = qobject_cast<TYPE*>(qobj); \
0195         if (! object ) \
0196             return nullptr; \
0197          
0198 #define KJSO_QOBJECT_END_BIND \
0199     }
0200 
0201 #define KJSO_QOBJECT_BIND( NAME, TYPE )\
0202     KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
0203     {\
0204         Q_UNUSED(exec);\
0205         QObject* qobj = pointer_cast<QObject>(&ptrObj); \
0206         if (! qobj ) \
0207             return nullptr; \
0208         TYPE* object = qobject_cast<TYPE*>(qobj); \
0209         if (! object ) \
0210             return nullptr; \
0211         return new NAME(exec, object); \
0212     }
0213 
0214 #define KJSO_VALUE_START_BIND( NAME, TYPE )\
0215     KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
0216     {\
0217         Q_UNUSED(exec);\
0218         TYPE* object = pointer_cast<TYPE>(&ptrObj); \
0219         if (! object ) \
0220             return nullptr; \
0221          
0222 #define KJSO_VALUE_END_BIND \
0223     }
0224 
0225 #define KJSO_VALUE_BIND( NAME, TYPE )\
0226     KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
0227     {\
0228         Q_UNUSED(exec);\
0229         TYPE* object = pointer_cast<TYPE>(&ptrObj); \
0230         if (! object ) \
0231             return nullptr; \
0232         return new NAME(exec, *object); \
0233     }
0234 
0235 namespace KJS
0236 {
0237 inline JSObject *throwError(ExecState *e, ErrorType t, const QString &m)
0238 {
0239     return throwError(e, t, KJSEmbed::toUString(m));
0240 }
0241 }
0242 
0243 namespace KJSEmbed
0244 {
0245 class KJSEMBED_EXPORT ProxyBinding : public KJS::JSObject
0246 {
0247 public:
0248     ProxyBinding(KJS::ExecState *exec);
0249     ~ProxyBinding() override {}
0250 
0251     bool implementsCall() const override
0252     {
0253         return true;
0254     }
0255     bool implementsConstruct() const override
0256     {
0257         return true;
0258     }
0259 };
0260 
0261 /**
0262 * This will extract a binding implementation from a KJS::JSValue
0263 * @code
0264 * KJSEmbed ObjectBindingImp *imp = extractBindingImp<ObjectBindingImp>(exec,val);
0265 * if( imp )
0266 *   qDebug("it worked");
0267 * else
0268 *   qDebug("it failed");
0269 * @endcode
0270 */
0271 template <typename T>
0272 T *extractBindingImp(KJS::ExecState *exec, KJS::JSValue *val)
0273 {
0274     return dynamic_cast<T *>(val->toObject(exec));
0275 }
0276 
0277 /**
0278 * This is just a helper function similar to the one above, only it takes a KJS::JSObject
0279 */
0280 template <typename T>
0281 T *extractBindingImp(KJS::JSObject *obj)
0282 {
0283     return dynamic_cast<T *>(obj);
0284 }
0285 
0286 /**
0287 * Method callback signature.
0288 * @param exec The execution state.
0289 * @param object The current object that the method is working on (equivalent of "this")
0290 * @param args A KJS::List of KJS::JSValue objects that represents the arguments that where
0291 * passed in from the javascript function signature.
0292 */
0293 typedef KJS::JSValue *(*callMethod)(KJS::ExecState *, KJS::JSObject *, const KJS::List &);
0294 
0295 /**
0296 * Method structure
0297 */
0298 struct KJSEMBED_EXPORT Method {
0299     /**
0300     * Method name as will appear in javascript
0301     */
0302     const char *name;
0303     /**
0304     * Number of arguments.
0305     */
0306     const int argc;
0307     /**
0308     * Flags for the member properties
0309     */
0310     const int flags;
0311     /**
0312     * The callback for the method.
0313     */
0314     const callMethod call;
0315 };
0316 
0317 /**
0318 * Enumerator structure
0319 */
0320 struct KJSEMBED_EXPORT Enumerator {
0321     /**
0322     * Method name as will appear in javascript
0323     */
0324     const char *name;
0325     /**
0326     * Integer value.
0327     */
0328     const unsigned int value;
0329 };
0330 
0331 /**
0332 * Bind signature
0333 * @param exec the execution context
0334 * @param ptr A PointerBase that points to a Pointer object that contains
0335 * a pointer to the object to provide a javascript binding for.
0336 */
0337 typedef KJS::JSObject *(*callBind)(KJS::ExecState *, PointerBase &);
0338 
0339 /**
0340 * Constructor signature
0341 * @param exec the execution context
0342 * @param args A KJS::List of KJS::JSValue objects that represents the arguments that where
0343 * passed in from the javascript function signature.
0344 */
0345 typedef KJS::JSObject *(*callConstructor)(KJS::ExecState *, const KJS::List &);
0346 
0347 struct KJSEMBED_EXPORT Constructor {
0348     /**
0349     * The constructor name as it will appear in Javascript.  This will be the objects
0350     * name as far as Javascript is concerned.
0351     */
0352     const char *name;
0353     /**
0354     * Number of arguments.
0355     */
0356     const int argc;
0357     /**
0358     * Flags for the member properties
0359     */
0360     const int flags;
0361     /**
0362     * The callback for the constructor.
0363     */
0364     const callBind bind;
0365     /**
0366     * The callback for the constructor.
0367     */
0368     const callConstructor construct;
0369     /**
0370     * Static methods on the object.
0371     */
0372     const Method *staticMethods;
0373     /**
0374     * Enumerators for the object
0375     */
0376     const Enumerator *enumerators;
0377     /**
0378     * Member methods for the object
0379     */
0380     const Method *methods;
0381 };
0382 
0383 /**
0384 * Extracts a QString from an argument list.  If the argument is not present, or is not convertable to a string
0385 * the defaultValue is returned.
0386 */
0387 QString KJSEMBED_EXPORT extractQString(KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue = QString());
0388 
0389 /**
0390 * Extract a QString from a value.  If the value cannot convert to a string the defaultValue is returned.
0391 */
0392 QString KJSEMBED_EXPORT extractQString(KJS::ExecState *exec, KJS::JSValue *value, const QString defaultValue = QString());
0393 
0394 /**
0395 * Create a new KJS::JSValue with the value of the QString
0396 */
0397 KJS::JSValue *createQString(KJS::ExecState *exec, const QString &value);
0398 
0399 /**
0400 * Extracts a QByteArray from an argument list.  If the argument is not present, or is not convertable to a string
0401 * the defaultValue is returned.
0402 */
0403 QByteArray KJSEMBED_EXPORT extractQByteArray(KJS::ExecState *exec, const KJS::List &args, int idx, const QByteArray &defaultValue = QByteArray());
0404 
0405 /**
0406 * Extract a QString from a value.  If the value cannot convert to a string the defaultValue is returned.
0407 */
0408 QByteArray KJSEMBED_EXPORT extractQByteArray(KJS::ExecState *exec, KJS::JSValue *value, const QByteArray &defaultValue = QByteArray());
0409 
0410 /**
0411 * Create a new KJS::JSValue with the value of the QString
0412 */
0413 KJS::JSValue *createQByteArray(KJS::ExecState *exec, const QByteArray &value);
0414 
0415 template<typename T>
0416 inline T KJSEMBED_EXPORT extractString(KJS::ExecState *exec, KJS::JSValue *value, T defaultValue = T())
0417 {
0418     if (!value || !value->isString()) {
0419         return defaultValue;
0420     }
0421 
0422     return (T)(value->toString(exec).ascii());
0423 }
0424 
0425 template<typename T>
0426 inline T KJSEMBED_EXPORT extractString(KJS::ExecState *exec, const KJS::List &args, int idx, T defaultValue = T())
0427 {
0428     if (args.size() >= idx) {
0429         return extractString<T>(exec, args[idx], defaultValue);
0430     } else {
0431         return defaultValue;
0432     }
0433 }
0434 
0435 /**
0436   * Extract a number from a value. If the value cannot convert to an integer or is not present defaultValue is returned
0437   */
0438 template<typename T>
0439 inline T KJSEMBED_EXPORT extractNumber(KJS::ExecState *exec, KJS::JSValue *value, T defaultValue = T(0))
0440 {
0441     if (!value || !value->isNumber()) {
0442         return defaultValue;
0443     }
0444 
0445     return static_cast<T>(value->toNumber(exec));
0446 }
0447 
0448 /**
0449  * Extracts a number from an arguments list. If the argument is not present, or is not convertable to a number
0450  * the defaultValue is returned.
0451  */
0452 template<typename T>
0453 inline T KJSEMBED_EXPORT extractNumber(KJS::ExecState *exec, const KJS::List &args, int idx, T defaultValue = T(0))
0454 {
0455     if (args.size() >= idx) {
0456         return extractNumber<T>(exec, args[idx], defaultValue);
0457     } else {
0458         return defaultValue;
0459     }
0460 }
0461 
0462 /**
0463   * Extract an integer from a value. If the value cannot convert to an integer or is not present defaultValue is returned
0464   */
0465 template<typename T>
0466 inline T KJSEMBED_EXPORT extractInteger(KJS::ExecState *exec, KJS::JSValue *value, T defaultValue)
0467 {
0468     if (!value || !value->isNumber()) {
0469         return defaultValue;
0470     }
0471 
0472 // deal with MSVC annoyances
0473 #if COMPILER(MSVC) || __GNUC__ == 3
0474     return static_cast<T>(static_cast<int>(value->toInteger(exec)));
0475 #else
0476     return static_cast<T>(value->toInteger(exec));
0477 #endif
0478 }
0479 
0480 // extractInteger specialization
0481 template<>
0482 inline qint32 KJSEMBED_EXPORT extractInteger<qint32>(KJS::ExecState *exec, KJS::JSValue *value, qint32 defaultValue)
0483 {
0484     if (!value || !value->isNumber()) {
0485         return defaultValue;
0486     }
0487 
0488     return static_cast<qint32>(value->toInt32(exec));
0489 }
0490 
0491 // extractInteger specialization
0492 template<>
0493 inline quint32 KJSEMBED_EXPORT extractInteger<quint32>(KJS::ExecState *exec, KJS::JSValue *value, quint32 defaultValue)
0494 {
0495     if (!value || !value->isNumber()) {
0496         return defaultValue;
0497     }
0498 
0499     return static_cast<quint32>(value->toUInt32(exec));
0500 }
0501 
0502 // extractInteger specialization
0503 template<>
0504 inline quint16 KJSEMBED_EXPORT extractInteger<quint16>(KJS::ExecState *exec, KJS::JSValue *value, quint16 defaultValue)
0505 {
0506     if (!value || !value->isNumber()) {
0507         return defaultValue;
0508     }
0509 
0510     return static_cast<quint16>(value->toUInt16(exec));
0511 }
0512 
0513 /**
0514  * Extracts an integer from an arguments list. If the argument is not present, or is not convertable to a number
0515  * the defaultValue is returned.
0516  */
0517 template<typename T>
0518 inline T KJSEMBED_EXPORT extractInteger(KJS::ExecState *exec, const KJS::List &args, int idx, T defaultValue = T(0))
0519 {
0520     if (args.size() >= idx) {
0521         return extractInteger<T>(exec, args[idx], defaultValue);
0522     } else {
0523         return defaultValue;
0524     }
0525 }
0526 
0527 /**
0528 * Extracts an integer from an argument list.  If the argument is not present, or is not convertable to an integer
0529 * the defaultValue is returned.
0530 */
0531 int KJSEMBED_EXPORT extractInt(KJS::ExecState *exec, const KJS::List &args, int idx, int defaultValue = 0);
0532 /**
0533 * Extract an integer from a value.  If the value cannot convert to an integer the defaultValue is returned.
0534 */
0535 int KJSEMBED_EXPORT extractInt(KJS::ExecState *exec, KJS::JSValue *value, int defaultValue = 0);
0536 /**
0537 * Create a new KJS::JSValue with the value of the integer.
0538 */
0539 KJS::JSValue *createInt(KJS::ExecState *exec, int value);
0540 
0541 /**
0542 * Extracts a double from an argument list.  If the argument is not present, or is not convertable to a double
0543 * the defaultValue is returned.
0544 */
0545 double KJSEMBED_EXPORT extractDouble(KJS::ExecState *exec, const KJS::List &args, int idx, double defaultValue = 0);
0546 /**
0547 * Extract a double from a value.  If the value cannot convert to a double the defaultValue is returned.
0548 */
0549 double KJSEMBED_EXPORT extractDouble(KJS::ExecState *exec, KJS::JSValue *value, double defaultValue = 0);
0550 /**
0551 * Create a new KJS::JSValue with the value of the double.
0552 */
0553 KJS::JSValue *createDouble(KJS::ExecState *exec, double value);
0554 
0555 /**
0556 * Extracts a float from an argument list.  If the argument is not present, or is not convertable to a float
0557 * the defaultValue is returned.
0558 */
0559 float KJSEMBED_EXPORT extractFloat(KJS::ExecState *exec, const KJS::List &args, int idx, float defaultValue = 0);
0560 /**
0561 * Extract a float from a value.  If the value cannot convert to a float the defaultValue is returned.
0562 */
0563 float KJSEMBED_EXPORT extractFloat(KJS::ExecState *exec, KJS::JSValue *value, float defaultValue = 0);
0564 /**
0565 * Create a new KJS::JSValue with the value of the float.
0566 */
0567 KJS::JSValue *createFloat(KJS::ExecState *exec, float value);
0568 
0569 /**
0570 * Extracts a bool from an argument list.  If the argument is not present, or is not convertable to a bool
0571 * the defaultValue is returned.
0572 */
0573 bool KJSEMBED_EXPORT extractBool(KJS::ExecState *exec, const KJS::List &args, int idx, bool defaultValue = false);
0574 /**
0575 * Extract a bool from a value.  If the value cannot convert to a bool the defaultValue is returned.
0576 */
0577 bool extractBool(KJS::ExecState *exec, KJS::JSValue *value, bool defaultValue = false);
0578 /**
0579 * Create a new KJS::JSValue with the value of the bool.
0580 */
0581 KJS::JSValue *createBool(KJS::ExecState *exec, bool value);
0582 
0583 /**
0584 * Extracts a QDateTime from an argument list.  If the argument is not present, or is not convertable to a QDateTime
0585 * the defaultValue is returned.
0586 */
0587 QDateTime KJSEMBED_EXPORT extractQDateTime(KJS::ExecState *exec, const KJS::List &args, int idx, const QDateTime &defaultValue = QDateTime());
0588 /**
0589 * Extract a bool from a value.  If the value cannot convert to a QDateTime the defaultValue is returned.
0590 */
0591 QDateTime KJSEMBED_EXPORT extractQDateTime(KJS::ExecState *exec, KJS::JSValue *value, const QDateTime &defaultValue = QDateTime());
0592 /**
0593 * Create a new KJS::JSValue with the value of the QDateTime.
0594 */
0595 KJS::JSValue *createQDateTime(KJS::ExecState *exec, const QDateTime &value);
0596 
0597 /**
0598 * Extracts a QDate from an argument list.  If the argument is not present, or is not convertable to a QDate
0599 * the defaultValue is returned.
0600 */
0601 QDate KJSEMBED_EXPORT extractQDate(KJS::ExecState *exec, const KJS::List &args, int idx, const QDate &defaultValue = QDate());
0602 /**
0603 * Extract a QDate from a value.  If the value cannot convert to a QDate the defaultValue is returned.
0604 */
0605 QDate KJSEMBED_EXPORT extractQDate(KJS::ExecState *exec, KJS::JSValue *value, const QDate &defaultValue = QDate());
0606 /**
0607 * Create a new KJS::JSValue with the value of the QDate.
0608 */
0609 KJS::JSValue *createQDate(KJS::ExecState *exec, const QDate &value);
0610 
0611 /**
0612 * Extracts a QTime from an argument list.  If the argument is not present, or is not convertable to a QTime
0613 * the defaultValue is returned.
0614 */
0615 QTime KJSEMBED_EXPORT extractQTime(KJS::ExecState *exec, const KJS::List &args, int idx, const QTime &defaultValue = QTime());
0616 /**
0617 * Extract a QTime from a value.  If the value cannot convert to a QTime the defaultValue is returned.
0618 */
0619 QTime KJSEMBED_EXPORT extractQTime(KJS::ExecState *exec, KJS::JSValue *value, const QTime &defaultValue = QTime());
0620 /**
0621 * Create a new KJS::JSValue with the value of the QTime.
0622 */
0623 KJS::JSValue *createQTime(KJS::ExecState *exec, const QTime &value);
0624 
0625 /**
0626 * Extracts a QStringList from an argument list. If the argument is not present, or is not convertable to a QStringList
0627 * the defaultValue is returned.
0628 */
0629 QStringList KJSEMBED_EXPORT extractQStringList(KJS::ExecState *exec, const KJS::List &args, int idx, const QStringList &defaultValue = QStringList());
0630 /**
0631 * Extract a QStringList from a value.  If the value cannot convert to a QStringList the defaultValue is returned.
0632 */
0633 QStringList KJSEMBED_EXPORT extractQStringList(KJS::ExecState *exec, KJS::JSValue *value, const QStringList &defaultValue = QStringList());
0634 /**
0635 * Create a new KJS::JSValue with the value of the QStringList.
0636 */
0637 KJS::JSValue *createQStringList(KJS::ExecState *exec, const QStringList &value);
0638 
0639 }
0640 
0641 #endif