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

KJSEmbed

KJSEmbed Namespace Reference


Classes

class  ProxyBinding
struct  Method
 Method structure. More...
struct  Enumerator
 Enumerator structure. More...
struct  Constructor
class  BrushBinding
class  BuiltinsFactory
class  ColorBinding
class  DomNodeBinding
class  DomDocumentBinding
class  DomElementBinding
class  DomAttrBinding
class  DomDocumentTypeBinding
class  DomNodeListBinding
class  DomNamedNodeMapBinding
class  DomTextBinding
class  EventProxy
 Filters events for a QObject and forwards them to a JS handler. More...
class  FileDialog
class  FileIOBinding
class  FontBinding
class  ImageBinding
class  IoFactory
class  JSEventMapper
 Maintains a map between the types of QEvent and the names of their event handlers. More...
class  Engine
 The main interface for running embedded Javascript. More...
class  ObjectFactory
class  ObjectBinding
class  PenBinding
class  PixmapBinding
class  PointBinding
class  QBrushBinding
class  QBrushData
class  QObjectBinding
class  SlotBinding
class  RectBinding
class  SizeBinding
class  SlotProxy
class  StaticBinding
 A binding method that is used in VariantBinding and ObjectBinding. More...
class  StaticConstructor
 A special method that will create other objects. More...
class  UrlBinding
class  ValueFactory
 The Bindings for the KJSEmbed::ValueBinding. More...
class  ValueBinding
 Value binding implementation. More...
class  VariantBinding
 QVariant based binding. More...
class  VariantFactory

Namespaces

namespace  JSEventUtils

Typedefs

typedef KJS::JSValue *(* callMethod )(KJS::ExecState *, KJS::JSObject *, const KJS::List &)
typedef KJS::JSObject *(* callBind )(KJS::ExecState *, PointerBase &)
typedef KJS::JSObject *(* callConstructor )(KJS::ExecState *, const KJS::List &)

Functions

KJSO_END_BINDING_CTOR return new CoreApplicationBinding (exec, QCoreApplication::instance())
KJSO_END_BINDING_CTOR return new ApplicationBinding (exec,::qobject_cast< QApplication * >(QCoreApplication::instance()))
return new QObjectBinding (exec, a)
QString extractQString (KJS::ExecState *exec, const KJS::List &args, int idx, const QString defaultValue=QString())
QString extractQString (KJS::ExecState *exec, KJS::JSValue *value, const QString defaultValue=QString())
QByteArray extractQByteArray (KJS::ExecState *exec, const KJS::List &args, int idx, const QByteArray &defaultValue=QByteArray())
QByteArray extractQByteArray (KJS::ExecState *exec, KJS::JSValue *value, const QByteArray &defaultValue=QByteArray())
KJS::JSValue * createQByteArray (KJS::ExecState *exec, const QByteArray &value)
int extractInt (KJS::ExecState *exec, const KJS::List &args, int idx, int defaultValue=0)
int extractInt (KJS::ExecState *exec, KJS::JSValue *value, int defaultValue=0)
KJS::JSValue * createQString (KJS::ExecState *exec, const QString &value)
KJS::JSValue * createInt (KJS::ExecState *exec, int value)
double extractDouble (KJS::ExecState *exec, const KJS::List &args, int idx, double defaultValue=0)
double extractDouble (KJS::ExecState *exec, KJS::JSValue *value, double defaultValue=0)
KJS::JSValue * createDouble (KJS::ExecState *exec, double value)
float extractFloat (KJS::ExecState *exec, const KJS::List &args, int idx, float defaultValue=0)
float extractFloat (KJS::ExecState *exec, KJS::JSValue *value, float defaultValue=0)
KJS::JSValue * createFloat (KJS::ExecState *exec, float value)
bool extractBool (KJS::ExecState *exec, const KJS::List &args, int idx, bool defaultValue=false)
bool extractBool (KJS::ExecState *exec, KJS::JSValue *value, bool defaultValue=false)
KJS::JSValue * createBool (KJS::ExecState *exec, bool value)
QDateTime extractQDateTime (KJS::ExecState *exec, const KJS::List &args, int idx, const QDateTime &defaultValue=QDateTime())
QDateTime extractQDateTime (KJS::ExecState *exec, KJS::JSValue *value, const QDateTime &defaultValue=QDateTime())
KJS::JSValue * createQDateTime (KJS::ExecState *exec, const QDateTime &value)
QDate extractQDate (KJS::ExecState *exec, const KJS::List &args, int idx, const QDate &defaultValue=QDate())
QDate extractQDate (KJS::ExecState *exec, KJS::JSValue *value, const QDate &defaultValue=QDate())
KJS::JSValue * createQDate (KJS::ExecState *exec, const QDate &value)
QTime extractQTime (KJS::ExecState *exec, const KJS::List &args, int idx, const QTime &defaultValue=QTime())
QTime extractQTime (KJS::ExecState *exec, KJS::JSValue *value, const QTime &defaultValue=QTime())
KJS::JSValue * createQTime (KJS::ExecState *exec, const QTime &value)
QStringList extractQStringList (KJS::ExecState *exec, const KJS::List &args, int idx, const QStringList &defaultValue=QStringList())
QStringList extractQStringList (KJS::ExecState *exec, KJS::JSValue *value, const QStringList &defaultValue=QStringList())
KJS::JSValue * createQStringList (KJS::ExecState *exec, const QStringList &value)
template<typename T>
T * extractBindingImp (KJS::ExecState *exec, KJS::JSValue *val)
template<typename T>
T * extractBindingImp (KJS::JSObject *obj)
template<typename T>
T extractString (KJS::ExecState *exec, KJS::JSValue *value, T defaultValue=T())
template<typename T>
T extractString (KJS::ExecState *exec, const KJS::List &args, int idx, T defaultValue=T())
template<typename T>
T extractNumber (KJS::ExecState *exec, KJS::JSValue *value, T defaultValue=T(0))
template<typename T>
T extractNumber (KJS::ExecState *exec, const KJS::List &args, int idx, T defaultValue=T(0))
template<typename T>
T extractInteger (KJS::ExecState *exec, KJS::JSValue *value, T defaultValue)
template<>
qint32 extractInteger< qint32 > (KJS::ExecState *exec, KJS::JSValue *value, qint32 defaultValue)
template<>
quint32 extractInteger< quint32 > (KJS::ExecState *exec, KJS::JSValue *value, quint32 defaultValue)
template<>
quint16 extractInteger< quint16 > (KJS::ExecState *exec, KJS::JSValue *value, quint16 defaultValue)
template<typename T>
T extractInteger (KJS::ExecState *exec, const KJS::List &args, int idx, T defaultValue=T(0))
return new DomDocumentBinding (exec, QDomDocument(name))
return new DomTextBinding (exec, QDomText())
QTextStream * conin ()
QTextStream * conout ()
QTextStream * conerr ()
QString toQString (const KJS::UString &u)
QString toQString (const KJS::Identifier &i)
KJS::UString toUString (const QString &qs)
void setup (KJS::ExecState *exec, KJS::JSObject *parent)
template<typename T>
T * extractObject (KJS::ExecState *exec, KJS::JSValue *arg, T *defaultValue)
template<typename T>
T * extractObject (KJS::ExecState *exec, const KJS::List &args, int idx, T *defaultValue=0L)
template<typename T>
KJS::JSValue * createObject (KJS::ExecState *exec, const KJS::UString &className, const T *value, KJSEmbed::ObjectBinding::Ownership owner=KJSEmbed::ObjectBinding::JSOwned)
template<typename T>
T extractParameter (KJS::ExecState *exec, KJS::JSValue *arg, const T &defaultValue)
QUiLoader * uiLoader ()
KJS::JSObject * createQObject (KJS::ExecState *exec, QObject *value, KJSEmbed::ObjectBinding::Ownership owner=KJSEmbed::ObjectBinding::JSOwned)
bool isBasic (KJS::JSValue *value)
bool isVariant (KJS::JSObject *object)
bool isObject (KJS::JSObject *object)
template<typename T>
T extractValue (KJS::ExecState *exec, KJS::JSValue *arg, const T &defaultValue)
template<typename T>
T extractValue (KJS::ExecState *exec, const KJS::List &args, int idx, const T &defaultValue=T())
template<typename T>
KJS::JSValue * createValue (KJS::ExecState *exec, const KJS::UString &className, const T &value)
QMap< QString, QVariant > convertArrayToMap (KJS::ExecState *exec, KJS::JSValue *value)
QList< QVariant > convertArrayToList (KJS::ExecState *exec, KJS::JSValue *value)
QStringList convertArrayToStringList (KJS::ExecState *exec, KJS::JSValue *value)
QVariant convertToVariant (KJS::ExecState *exec, KJS::JSValue *value)
KJS::JSValue * convertToValue (KJS::ExecState *exec, const QVariant &value)
QVariant extractVariant (KJS::ExecState *exec, KJS::JSValue *value)
template<typename T>
T extractVariant (KJS::ExecState *exec, KJS::JSValue *arg, const T &defaultValue)
template<typename T>
T extractVariant (KJS::ExecState *exec, const KJS::List &args, int idx, const T &defaultValue=T())
template<typename T>
KJS::JSValue * createVariant (KJS::ExecState *exec, const KJS::UString &className, const T &value)

Variables

static EventType events []
static QUiLoader * gUiLoader = 0L
static QHash< QString, const
Constructor * > 
g_ctorHash

Typedef Documentation

typedef KJS::JSObject*(* KJSEmbed::callBind)(KJS::ExecState *, PointerBase &)

Bind signature.

  • exec - the execution context
  • ptr - A PointerBase that points to a Pointer object that contains a pointer to the object to provide a javascript binding for.

Definition at line 335 of file binding_support.h.

typedef KJS::JSObject*(* KJSEmbed::callConstructor)(KJS::ExecState *, const KJS::List &)

Constructor signature.

  • exec - the execution context
  • args - A KJS::List of KJS::JSValue objects that represents the arguments that where passed in from the javascript function signature.

Definition at line 343 of file binding_support.h.

typedef KJS::JSValue*(* KJSEmbed::callMethod)(KJS::ExecState *, KJS::JSObject *, const KJS::List &)

Method callback signature.

  • exec - The execution state.
  • object - The current object that the method is working on (equivelent of "this")
  • args - A KJS::List of KJS::JSValue objects that represents the arguments that where passed in from the javascript function signature.

Definition at line 289 of file binding_support.h.


Function Documentation

KJSO_END_BINDING_CTOR return new KJSEmbed::ApplicationBinding ( exec  ,
::qobject_cast< QApplication * >  (QCoreApplication::instance()) 
)

QTextStream * KJSEmbed::conerr (  ) 

Definition at line 172 of file kjseglobal.cpp.

QTextStream * KJSEmbed::conin (  ) 

Definition at line 147 of file kjseglobal.cpp.

QTextStream * KJSEmbed::conout (  ) 

Definition at line 159 of file kjseglobal.cpp.

QList< QVariant > KJSEmbed::convertArrayToList ( KJS::ExecState *  exec,
KJS::JSValue *  value 
)

Convert a KJS::JSValue into a QList.

If the list contains only strings, or objects that can be converted to strings you can call to convertArrayToStringList. If you call this on an associative array or a javascript object the list will return empty. Unless there happens to be a property with a numeric index present, then all bets are off.

Definition at line 169 of file variant_binding.cpp.

QMap< QString, QVariant > KJSEmbed::convertArrayToMap ( KJS::ExecState *  exec,
KJS::JSValue *  value 
)

Convert a KJS::JSValue that contains an associative array into a QMap.

If you call this on a normal Javascript object you will get each property as the key and its data as the value. A normal array will give you a QMap with each key being the index.

Definition at line 153 of file variant_binding.cpp.

QStringList KJSEmbed::convertArrayToStringList ( KJS::ExecState *  exec,
KJS::JSValue *  value 
)

Convert a KJS::JSValue inot a QStringList.

See also:
convertArrayToList.

Definition at line 199 of file variant_binding.cpp.

KJS::JSValue * KJSEmbed::convertToValue ( KJS::ExecState *  exec,
const QVariant &  value 
)

Convert a QVariant to a KJS::JSValue.

If the type is a known type the bindings will be added. If the type is supported by QVariant, but is not supported by KJSEmbed then it will just be wrapped. This wrapped value can be used just like normal value bindings, save for the lack of methods available to the object.

Definition at line 319 of file variant_binding.cpp.

QVariant KJSEmbed::convertToVariant ( KJS::ExecState *  exec,
KJS::JSValue *  value 
)

Convert a KJS::JSValue into a QVariant object.

Definition at line 261 of file variant_binding.cpp.

KJSO_END_BINDING_CTOR return new KJSEmbed::CoreApplicationBinding ( exec  ,
QCoreApplication::  instance() 
)

KJS::JSValue * KJSEmbed::createBool ( KJS::ExecState *  exec,
bool  value 
)

Create a new KJS::JSValue with the value of the bool.

Definition at line 167 of file binding_support.cpp.

KJS::JSValue * KJSEmbed::createDouble ( KJS::ExecState *  exec,
double  value 
)

Create a new KJS::JSValue with the value of the double.

Definition at line 117 of file binding_support.cpp.

KJS::JSValue * KJSEmbed::createFloat ( KJS::ExecState *  exec,
float  value 
)

Create a new KJS::JSValue with the value of the float.

Definition at line 142 of file binding_support.cpp.

KJS::JSValue * KJSEmbed::createInt ( KJS::ExecState *  exec,
int  value 
)

Create a new KJS::JSValue with the value of the integer.

Definition at line 94 of file binding_support.cpp.

template<typename T>
KJS::JSValue* KJSEmbed::createObject ( KJS::ExecState *  exec,
const KJS::UString &  className,
const T *  value,
KJSEmbed::ObjectBinding::Ownership  owner = KJSEmbed::ObjectBinding::JSOwned 
) [inline]

Can create any known KJSEmbed::ObjectBinding object and set the value.

On failure a KJS::jsNull will be returned and the exception set.

Definition at line 200 of file object_binding.h.

KJS::JSValue * KJSEmbed::createQByteArray ( KJS::ExecState *  exec,
const QByteArray &  value 
)

Create a new KJS::JSValue with the value of the QString.

Definition at line 66 of file binding_support.cpp.

KJS::JSValue * KJSEmbed::createQDate ( KJS::ExecState *  ,
const QDate &   
)

Create a new KJS::JSValue with the value of the QDate.

Definition at line 205 of file binding_support.cpp.

KJS::JSValue * KJSEmbed::createQDateTime ( KJS::ExecState *  ,
const QDateTime &   
)

Create a new KJS::JSValue with the value of the QDateTime.

Definition at line 186 of file binding_support.cpp.

KJS::JSObject * KJSEmbed::createQObject ( KJS::ExecState *  exec,
QObject *  value,
KJSEmbed::ObjectBinding::Ownership  owner = KJSEmbed::ObjectBinding::JSOwned 
)

Returns a binding object for the specified QObject.

This method walks up the meta objects in order to find the most specific binding it can. There should always be some kind of binding possible even if it is just the QObject binding.

Parameters:
exec Represents the current state of script execution.
value The QObject or from it inherited instance we should return a binding object for.
owner Defines who's the owner of the QObject. This could be;
  • CPPOwned what means, that the QObject's lifetime is handled within C++ code. So, we just provide access to it and don't take any future actions.
  • QObjOwned means that the QObject got deleted if the parent QObject is destroyed. If the QObject has no parent QObject, it behaves like JSOwned.
  • JSOwned means, that the returned KJS::JSObject takes care of deleting the QObject. This means, that the QObject got deleted as soon as the KJS::JSObject got destroyed what happens if the KJS::JSObject is not needed / in use any longer.
Returns:
the binding object instance that wraps the QObject instance or a JSObject with a prototype of jsNull (that is, the ECMAScript "null" value, not a null object pointer) if we failed to provide any binding for it.

Definition at line 703 of file qobject_binding.cpp.

KJS::JSValue * KJSEmbed::createQString ( KJS::ExecState *  exec,
const QString &  value 
)

Create a new KJS::JSValue with the value of the QString.

Definition at line 88 of file binding_support.cpp.

KJS::JSValue * KJSEmbed::createQStringList ( KJS::ExecState *  ,
const QStringList &   
)

Create a new KJS::JSValue with the value of the QStringList.

Definition at line 243 of file binding_support.cpp.

KJS::JSValue * KJSEmbed::createQTime ( KJS::ExecState *  ,
const QTime &   
)

Create a new KJS::JSValue with the value of the QTime.

Definition at line 224 of file binding_support.cpp.

template<typename T>
KJS::JSValue* KJSEmbed::createValue ( KJS::ExecState *  exec,
const KJS::UString &  className,
const T &  value 
) [inline]

Definition at line 195 of file value_binding.h.

template<typename T>
KJS::JSValue* KJSEmbed::createVariant ( KJS::ExecState *  exec,
const KJS::UString &  className,
const T &  value 
) [inline]

Can create any known KJSEmbed::VariantBinding object and set the value.

On failure a KJS::jsNull will be returned and the exception set. Only values that are supported by QVariant will work.

Definition at line 184 of file variant_binding.h.

return new KJSEmbed::DomDocumentBinding ( exec  ,
QDomDocument(name)   
)

return new KJSEmbed::DomTextBinding ( exec  ,
QDomText()   
)

template<typename T>
T* KJSEmbed::extractBindingImp ( KJS::JSObject *  obj  )  [inline]

This is just a helper function similar to the one above, only it takes a KJS::JSObject.

Definition at line 277 of file binding_support.h.

template<typename T>
T* KJSEmbed::extractBindingImp ( KJS::ExecState *  exec,
KJS::JSValue *  val 
) [inline]

This will extract a binding implementation from a KJS::JSValue.

 KJSEmbed ObjectBindingImp *imp = extractBindingImp<ObjectBindingImp>(exec,val);
 if( imp )
    qDebug("it worked");
 else
    qDebug("it failed");

Definition at line 268 of file binding_support.h.

bool KJSEmbed::extractBool ( KJS::ExecState *  exec,
KJS::JSValue *  value,
bool  defaultValue = false 
)

Extract a bool from a value.

If the value cannot convert to a bool the defaultValue is returned.

Definition at line 159 of file binding_support.cpp.

bool KJSEmbed::extractBool ( KJS::ExecState *  exec,
const KJS::List &  args,
int  idx,
bool  defaultValue = false 
)

Extracts a bool from an argument list.

If the argument is not present, or is not convertable to a bool the defaultValue is returned.

Definition at line 149 of file binding_support.cpp.

double KJSEmbed::extractDouble ( KJS::ExecState *  exec,
KJS::JSValue *  value,
double  defaultValue = 0 
)

Extract a double from a value.

If the value cannot convert to a double the defaultValue is returned.

Definition at line 109 of file binding_support.cpp.

double KJSEmbed::extractDouble ( KJS::ExecState *  exec,
const KJS::List &  args,
int  idx,
double  defaultValue = 0 
)

Extracts a double from an argument list.

If the argument is not present, or is not convertable to a double the defaultValue is returned.

Definition at line 100 of file binding_support.cpp.

float KJSEmbed::extractFloat ( KJS::ExecState *  exec,
KJS::JSValue *  value,
float  defaultValue = 0 
)

Extract a float from a value.

If the value cannot convert to a float the defaultValue is returned.

Definition at line 134 of file binding_support.cpp.

float KJSEmbed::extractFloat ( KJS::ExecState *