• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

kjsembed

  • sources
  • kde-4.12
  • kdelibs
  • kjsembed
  • kjsembed
binding_support.cpp
Go to the documentation of this file.
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 #include "binding_support.h"
23 #include <kjs/interpreter.h>
24 
25 
26 using namespace KJSEmbed;
27 
28 ProxyBinding::ProxyBinding( KJS::ExecState *exec )
29  : KJS::JSObject(exec->lexicalInterpreter()->builtinObjectPrototype())
30 {
31 
32 }
33 
34 QString KJSEmbed::extractQString( KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue )
35 {
36  if( args.size() > idx )
37  {
38  return extractQString( exec, args[idx] );
39  }
40  return defaultValue;
41 }
42 
43 QString KJSEmbed::extractQString( KJS::ExecState *exec, KJS::JSValue *value, const QString defaultValue )
44 {
45  if( !value )
46  return defaultValue;
47  return toQString(value->toString(exec));
48 }
49 
50 QByteArray KJSEmbed::extractQByteArray( KJS::ExecState *exec, const KJS::List &args, int idx, const QByteArray &defaultValue )
51 {
52  if( args.size() > idx )
53  {
54  return extractQByteArray( exec, args[idx] );
55  }
56  return defaultValue;
57 }
58 
59 QByteArray KJSEmbed::extractQByteArray( KJS::ExecState *exec, KJS::JSValue *value, const QByteArray &defaultValue )
60 {
61  if( !value )
62  return defaultValue;
63  return toQString(value->toString(exec)).toLatin1();
64 }
65 
66 KJS::JSValue *KJSEmbed::createQByteArray( KJS::ExecState *exec, const QByteArray &value )
67 {
68  Q_UNUSED( exec );
69  return KJS::jsString( value.data() );
70 }
71 
72 int KJSEmbed::extractInt( KJS::ExecState *exec, const KJS::List &args, int idx, int defaultValue )
73 {
74  if( args.size() > idx )
75  {
76  return extractInt( exec, args[idx] );
77  }
78  return defaultValue;
79 }
80 
81 int KJSEmbed::extractInt( KJS::ExecState *exec, KJS::JSValue *value, int defaultValue )
82 {
83  if( !value )
84  return defaultValue;
85  return int( value->toInteger(exec) );
86 }
87 
88 KJS::JSValue *KJSEmbed::createQString( KJS::ExecState *exec, const QString &value )
89 {
90  Q_UNUSED( exec );
91  return KJS::jsString( toUString(value) );
92 }
93 
94 KJS::JSValue *KJSEmbed::createInt( KJS::ExecState *exec, int value )
95 {
96  Q_UNUSED( exec );
97  return KJS::jsNumber( value );
98 }
99 
100 double KJSEmbed::extractDouble( KJS::ExecState *exec, const KJS::List &args, int idx, double defaultValue )
101 {
102  if( args.size() > idx )
103  {
104  return extractDouble( exec, args[idx] );
105  }
106  return defaultValue;
107 }
108 
109 double KJSEmbed::extractDouble( KJS::ExecState *exec, KJS::JSValue *value, double defaultValue )
110 {
111  if( !value )
112  return defaultValue;
113  return (double) value->toNumber(exec);
114 }
115 
116 
117 KJS::JSValue *KJSEmbed::createDouble( KJS::ExecState *exec, double value )
118 {
119  Q_UNUSED( exec );
120  return KJS::jsNumber( value );
121 }
122 
123 
124 float KJSEmbed::extractFloat( KJS::ExecState *exec, const KJS::List &args, int idx, float defaultValue )
125 {
126  if( args.size() > idx )
127  {
128  return extractFloat( exec, args[idx] );
129  }
130  return defaultValue;
131 }
132 
133 
134 float KJSEmbed::extractFloat( KJS::ExecState *exec, KJS::JSValue *value, float defaultValue )
135 {
136  if( !value )
137  return defaultValue;
138  return (float) value->toNumber(exec);
139 }
140 
141 
142 KJS::JSValue *KJSEmbed::createFloat( KJS::ExecState *exec, float value )
143 {
144  Q_UNUSED( exec );
145  return KJS::jsNumber( value );
146 }
147 
148 
149 bool KJSEmbed::extractBool( KJS::ExecState *exec, const KJS::List &args, int idx, bool defaultValue )
150 {
151  if( args.size() > idx )
152  {
153  return extractBool( exec, args[idx] );
154  }
155  return defaultValue;
156 }
157 
158 
159 bool KJSEmbed::extractBool( KJS::ExecState *exec, KJS::JSValue *value, bool defaultValue )
160 {
161  if( !value )
162  return defaultValue;
163  return value->toBoolean(exec);
164 }
165 
166 
167 KJS::JSValue *KJSEmbed::createBool( KJS::ExecState *exec, bool value )
168 {
169  Q_UNUSED( exec );
170  return KJS::jsBoolean( value );
171 }
172 
173 
174 QDateTime KJSEmbed::extractQDateTime( KJS::ExecState* /* exec */, const KJS::List& /* args */, int /* idx */, const QDateTime& /* defaultValue */ )
175 {
176  return QDateTime();
177 }
178 
179 
180 QDateTime KJSEmbed::extractQDateTime( KJS::ExecState* /* exec */, KJS::JSValue* /* value */, const QDateTime& /* defaultValue */ )
181 {
182  return QDateTime();
183 }
184 
185 
186 KJS::JSValue *KJSEmbed::createQDateTime( KJS::ExecState* /* exec */, const QDateTime& /* value */ )
187 {
188 // return new KJS::JSValue();
189  return 0;
190 }
191 
192 
193 QDate KJSEmbed::extractQDate( KJS::ExecState* /* exec */, const KJS::List& /* args */, int /* idx */, const QDate& /* defaultValue */ )
194 {
195  return QDate();
196 }
197 
198 
199 QDate KJSEmbed::extractQDate( KJS::ExecState* /*exec*/, KJS::JSValue* /*value*/, const QDate& /*defaultValue*/ )
200 {
201  return QDate();
202 }
203 
204 
205 KJS::JSValue *KJSEmbed::createQDate( KJS::ExecState* /*exec*/, const QDate& /*value*/ )
206 {
207 // return new KJS::JSValue();
208  return 0;
209 }
210 
211 
212 QTime KJSEmbed::extractQTime( KJS::ExecState* /*exec*/, const KJS::List& /*args*/, int /*idx*/, const QTime& /*defaultValue*/ )
213 {
214  return QTime();
215 }
216 
217 
218 QTime KJSEmbed::extractQTime( KJS::ExecState * /*exec*/, KJS::JSValue* /*value*/, const QTime &/*defaultValue*/ )
219 {
220  return QTime();
221 }
222 
223 
224 KJS::JSValue *KJSEmbed::createQTime( KJS::ExecState * /*exec*/, const QTime &/*value*/ )
225 {
226 // return new KJS::JSValue();
227  return 0;
228 }
229 
230 
231 QStringList KJSEmbed::extractQStringList( KJS::ExecState * /*exec*/, const KJS::List &/*args*/, int /*idx*/, const QStringList &/*defaultValue*/ )
232 {
233  return QStringList();
234 }
235 
236 
237 QStringList KJSEmbed::extractQStringList( KJS::ExecState * /*exec*/, KJS::JSValue* /*value*/, const QStringList &/*defaultValue*/ )
238 {
239  return QStringList();
240 }
241 
242 
243 KJS::JSValue *KJSEmbed::createQStringList( KJS::ExecState * /*exec*/, const QStringList &/*value*/ )
244 {
245 // return new KJS::JSValue();
246  return 0;
247 }
248 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
249 
250 
KJSEmbed::createQString
KJS::JSValue * createQString(KJS::ExecState *exec, const QString &value)
Create a new KJS::JSValue with the value of the QString.
Definition: binding_support.cpp:88
KJSEmbed::createQTime
KJS::JSValue * createQTime(KJS::ExecState *exec, const QTime &value)
Create a new KJS::JSValue with the value of the QTime.
Definition: binding_support.cpp:224
KJSEmbed::extractQTime
QTime KJSEMBED_EXPORT extractQTime(KJS::ExecState *exec, const KJS::List &args, int idx, const QTime &defaultValue=QTime())
Extracts a QTime from an argument list.
Definition: binding_support.cpp:212
KJSEmbed::createQByteArray
KJS::JSValue * createQByteArray(KJS::ExecState *exec, const QByteArray &value)
Create a new KJS::JSValue with the value of the QString.
Definition: binding_support.cpp:66
KJSEmbed::extractBool
bool KJSEMBED_EXPORT extractBool(KJS::ExecState *exec, const KJS::List &args, int idx, bool defaultValue=false)
Extracts a bool from an argument list.
Definition: binding_support.cpp:149
KJSEmbed::extractInt
int KJSEMBED_EXPORT extractInt(KJS::ExecState *exec, const KJS::List &args, int idx, int defaultValue=0)
Extracts an integer from an argument list.
Definition: binding_support.cpp:72
binding_support.h
KJSEmbed::ProxyBinding::ProxyBinding
ProxyBinding(KJS::ExecState *exec)
Definition: binding_support.cpp:28
KJSEmbed::createBool
KJS::JSValue * createBool(KJS::ExecState *exec, bool value)
Create a new KJS::JSValue with the value of the bool.
Definition: binding_support.cpp:167
KJSEmbed::createQStringList
KJS::JSValue * createQStringList(KJS::ExecState *exec, const QStringList &value)
Create a new KJS::JSValue with the value of the QStringList.
Definition: binding_support.cpp:243
KJSEmbed::extractQDateTime
QDateTime KJSEMBED_EXPORT extractQDateTime(KJS::ExecState *exec, const KJS::List &args, int idx, const QDateTime &defaultValue=QDateTime())
Extracts a QDateTime from an argument list.
Definition: binding_support.cpp:174
DomElementNS::defaultValue
QString defaultValue
Definition: dom.cpp:506
KJSEmbed::createInt
KJS::JSValue * createInt(KJS::ExecState *exec, int value)
Create a new KJS::JSValue with the value of the integer.
Definition: binding_support.cpp:94
KJSEmbed::extractQStringList
QStringList KJSEMBED_EXPORT extractQStringList(KJS::ExecState *exec, const KJS::List &args, int idx, const QStringList &defaultValue=QStringList())
Extracts a QStringList from an argument list.
Definition: binding_support.cpp:231
KJSEmbed::createFloat
KJS::JSValue * createFloat(KJS::ExecState *exec, float value)
Create a new KJS::JSValue with the value of the float.
Definition: binding_support.cpp:142
KJSEmbed::extractQByteArray
QByteArray KJSEMBED_EXPORT extractQByteArray(KJS::ExecState *exec, const KJS::List &args, int idx, const QByteArray &defaultValue=QByteArray())
Extracts a QByteArray from an argument list.
Definition: binding_support.cpp:50
KJSEmbed::extractFloat
float KJSEMBED_EXPORT extractFloat(KJS::ExecState *exec, const KJS::List &args, int idx, float defaultValue=0)
Extracts a float from an argument list.
Definition: binding_support.cpp:124
KJSEmbed::createQDateTime
KJS::JSValue * createQDateTime(KJS::ExecState *exec, const QDateTime &value)
Create a new KJS::JSValue with the value of the QDateTime.
Definition: binding_support.cpp:186
NodeListNS::idx
END_VALUE_METHOD int idx
Definition: dom.cpp:691
KJS::jsString
KJS::JSCell * jsString(const QString &s)
Definition: kjseglobal.h:73
List
Definition: variant_binding.cpp:130
KJSEmbed::createQDate
KJS::JSValue * createQDate(KJS::ExecState *exec, const QDate &value)
Create a new KJS::JSValue with the value of the QDate.
Definition: binding_support.cpp:205
KJSEmbed::createDouble
KJS::JSValue * createDouble(KJS::ExecState *exec, double value)
Create a new KJS::JSValue with the value of the double.
Definition: binding_support.cpp:117
KJSEmbed::toUString
KJS::UString toUString(const QString &qs)
Definition: kjseglobal.h:66
KJSEmbed::extractQDate
QDate KJSEMBED_EXPORT extractQDate(KJS::ExecState *exec, const KJS::List &args, int idx, const QDate &defaultValue=QDate())
Extracts a QDate from an argument list.
Definition: binding_support.cpp:193
value
QVariant value
Definition: settings.cpp:35
KJSEmbed::extractQString
QString KJSEMBED_EXPORT extractQString(KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue=QString())
Extracts a QString from an argument list.
Definition: binding_support.cpp:34
KJSEmbed::extractDouble
double KJSEMBED_EXPORT extractDouble(KJS::ExecState *exec, const KJS::List &args, int idx, double defaultValue=0)
Extracts a double from an argument list.
Definition: binding_support.cpp:100
KJSEmbed::toQString
QString toQString(const KJS::UString &u)
Definition: kjseglobal.h:58
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kjsembed

Skip menu "kjsembed"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal