00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "binding_support.h"
00023 #include <kjs/interpreter.h>
00024
00025
00026 using namespace KJSEmbed;
00027
00028 ProxyBinding::ProxyBinding( KJS::ExecState *exec )
00029 : KJS::JSObject(exec->lexicalInterpreter()->builtinObjectPrototype())
00030 {
00031
00032 }
00033
00034 QString KJSEmbed::extractQString( KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue )
00035 {
00036 if( args.size() > idx )
00037 {
00038 return extractQString( exec, args[idx] );
00039 }
00040 return defaultValue;
00041 }
00042
00043 QString KJSEmbed::extractQString( KJS::ExecState *exec, KJS::JSValue *value, const QString defaultValue )
00044 {
00045 if( !value )
00046 return defaultValue;
00047 return toQString(value->toString(exec));
00048 }
00049
00050 QByteArray KJSEmbed::extractQByteArray( KJS::ExecState *exec, const KJS::List &args, int idx, const QByteArray &defaultValue )
00051 {
00052 if( args.size() > idx )
00053 {
00054 return extractQByteArray( exec, args[idx] );
00055 }
00056 return defaultValue;
00057 }
00058
00059 QByteArray KJSEmbed::extractQByteArray( KJS::ExecState *exec, KJS::JSValue *value, const QByteArray &defaultValue )
00060 {
00061 if( !value )
00062 return defaultValue;
00063 return toQString(value->toString(exec)).toLatin1();
00064 }
00065
00066 KJS::JSValue *KJSEmbed::createQByteArray( KJS::ExecState *exec, const QByteArray &value )
00067 {
00068 Q_UNUSED( exec );
00069 return KJS::jsString( value.data() );
00070 }
00071
00072 int KJSEmbed::extractInt( KJS::ExecState *exec, const KJS::List &args, int idx, int defaultValue )
00073 {
00074 if( args.size() > idx )
00075 {
00076 return extractInt( exec, args[idx] );
00077 }
00078 return defaultValue;
00079 }
00080
00081 int KJSEmbed::extractInt( KJS::ExecState *exec, KJS::JSValue *value, int defaultValue )
00082 {
00083 if( !value )
00084 return defaultValue;
00085 return int( value->toInteger(exec) );
00086 }
00087
00088 KJS::JSValue *KJSEmbed::createQString( KJS::ExecState *exec, const QString &value )
00089 {
00090 Q_UNUSED( exec );
00091 return KJS::jsString( toUString(value) );
00092 }
00093
00094 KJS::JSValue *KJSEmbed::createInt( KJS::ExecState *exec, int value )
00095 {
00096 Q_UNUSED( exec );
00097 return KJS::jsNumber( value );
00098 }
00099
00100 double KJSEmbed::extractDouble( KJS::ExecState *exec, const KJS::List &args, int idx, double defaultValue )
00101 {
00102 if( args.size() > idx )
00103 {
00104 return extractDouble( exec, args[idx] );
00105 }
00106 return defaultValue;
00107 }
00108
00109 double KJSEmbed::extractDouble( KJS::ExecState *exec, KJS::JSValue *value, double defaultValue )
00110 {
00111 if( !value )
00112 return defaultValue;
00113 return (double) value->toNumber(exec);
00114 }
00115
00116
00117 KJS::JSValue *KJSEmbed::createDouble( KJS::ExecState *exec, double value )
00118 {
00119 Q_UNUSED( exec );
00120 return KJS::jsNumber( value );
00121 }
00122
00123
00124 float KJSEmbed::extractFloat( KJS::ExecState *exec, const KJS::List &args, int idx, float defaultValue )
00125 {
00126 if( args.size() > idx )
00127 {
00128 return extractFloat( exec, args[idx] );
00129 }
00130 return defaultValue;
00131 }
00132
00133
00134 float KJSEmbed::extractFloat( KJS::ExecState *exec, KJS::JSValue *value, float defaultValue )
00135 {
00136 if( !value )
00137 return defaultValue;
00138 return (float) value->toNumber(exec);
00139 }
00140
00141
00142 KJS::JSValue *KJSEmbed::createFloat( KJS::ExecState *exec, float value )
00143 {
00144 Q_UNUSED( exec );
00145 return KJS::jsNumber( value );
00146 }
00147
00148
00149 bool KJSEmbed::extractBool( KJS::ExecState *exec, const KJS::List &args, int idx, bool defaultValue )
00150 {
00151 if( args.size() > idx )
00152 {
00153 return extractBool( exec, args[idx] );
00154 }
00155 return defaultValue;
00156 }
00157
00158
00159 bool KJSEmbed::extractBool( KJS::ExecState *exec, KJS::JSValue *value, bool defaultValue )
00160 {
00161 if( !value )
00162 return defaultValue;
00163 return value->toBoolean(exec);
00164 }
00165
00166
00167 KJS::JSValue *KJSEmbed::createBool( KJS::ExecState *exec, bool value )
00168 {
00169 Q_UNUSED( exec );
00170 return KJS::jsBoolean( value );
00171 }
00172
00173
00174 QDateTime KJSEmbed::extractQDateTime( KJS::ExecState* , const KJS::List& , int , const QDateTime& )
00175 {
00176 return QDateTime();
00177 }
00178
00179
00180 QDateTime KJSEmbed::extractQDateTime( KJS::ExecState* , KJS::JSValue* , const QDateTime& )
00181 {
00182 return QDateTime();
00183 }
00184
00185
00186 KJS::JSValue *KJSEmbed::createQDateTime( KJS::ExecState* , const QDateTime& )
00187 {
00188
00189 return 0;
00190 }
00191
00192
00193 QDate KJSEmbed::extractQDate( KJS::ExecState* , const KJS::List& , int , const QDate& )
00194 {
00195 return QDate();
00196 }
00197
00198
00199 QDate KJSEmbed::extractQDate( KJS::ExecState* , KJS::JSValue* , const QDate& )
00200 {
00201 return QDate();
00202 }
00203
00204
00205 KJS::JSValue *KJSEmbed::createQDate( KJS::ExecState* , const QDate& )
00206 {
00207
00208 return 0;
00209 }
00210
00211
00212 QTime KJSEmbed::extractQTime( KJS::ExecState* , const KJS::List& , int , const QTime& )
00213 {
00214 return QTime();
00215 }
00216
00217
00218 QTime KJSEmbed::extractQTime( KJS::ExecState * , KJS::JSValue* , const QTime & )
00219 {
00220 return QTime();
00221 }
00222
00223
00224 KJS::JSValue *KJSEmbed::createQTime( KJS::ExecState * , const QTime & )
00225 {
00226
00227 return 0;
00228 }
00229
00230
00231 QStringList KJSEmbed::extractQStringList( KJS::ExecState * , const KJS::List &, int , const QStringList & )
00232 {
00233 return QStringList();
00234 }
00235
00236
00237 QStringList KJSEmbed::extractQStringList( KJS::ExecState * , KJS::JSValue* , const QStringList & )
00238 {
00239 return QStringList();
00240 }
00241
00242
00243 KJS::JSValue *KJSEmbed::createQStringList( KJS::ExecState * , const QStringList & )
00244 {
00245
00246 return 0;
00247 }
00248
00249
00250