kjsembed
qobject_binding.cpp
Go to the documentation of this file.
115 KJSEmbed::QObjectBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::QObjectBinding>(exec, self );
116 if( !imp ) // No implementation, so we need to use the first argument as we are a global static invocation.
124 KJSEmbed::QObjectBinding *senderImp = KJSEmbed::extractBindingImp<KJSEmbed::QObjectBinding>(exec, args[0] );
140 receiver = new SlotProxy(args[2]->toObject(exec), exec->dynamicInterpreter(), sender, args[3]->toString(exec).ascii() );
152 QMetaMethod senderMetaMethod = senderMetaObject->method( senderMetaObject->indexOfSignal(signal.constData()) );
155 QMetaMethod receiverMetaMethod = receiverMetaObject->method( receiverMetaObject->indexOfSlot(slot.constData()) );
157 if( validSignal(senderMetaMethod, senderImp->access()) && ( !receiverImp || validSlot(receiverMetaMethod, receiverImp->access()) ) )
159 return KJS::jsBoolean(QObject::connect(sender, signal.constData(), receiver, slot.constData()));
174 void QObjectBinding::publishQObject( KJS::ExecState *exec, KJS::JSObject *target, QObject *object)
176 KJSEmbed::QObjectBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::QObjectBinding>(exec, target);
192 KJSEmbed::QObjectBinding *childImp = KJSEmbed::extractBindingImp<KJSEmbed::QObjectBinding>(exec, childObject);
250 exec->dynamicInterpreter()->globalObject()->put(exec, "connect", new StaticBinding(exec, &QObjectFactory::methods()[0]) );
281 bool QObjectBinding::getOwnPropertySlot( KJS::ExecState *exec, const KJS::Identifier &propertyName, KJS::PropertySlot &slot )
308 qDebug() << QString("propertyGetter called but no property, name was '%1'").arg(propertyName.ascii());
322 void QObjectBinding::put(KJS::ExecState *exec, const KJS::Identifier &propertyName, KJS::JSValue *value, int attr )
350 i18n("Setting property %1 failed: property invalid, read-only or does not exist").arg(propertyName.ascii()));
401 PointerBase *getArg( KJS::ExecState *exec, const QList<QByteArray> &types, const KJS::List &args, int idx, QString& errorText)
412 const QString firstPart = i18np("The slot asked for %1 argument", "The slot asked for %1 arguments", idx);
413 const QString secondPart = i18np("but there is only %1 available", "but there are only %1 available", types.size());
414 errorText = i18nc("%1 is 'the slot asked for foo arguments', %2 is 'but there are only bar available'", "%1, %2.");
420 //qDebug( QString("type=%1 argtype=%2 variantType=%3 (%4)").arg(types[idx].constData()).arg(args[idx]->type()).arg(varianttype).arg(QVariant::typeToName(varianttype)).toLatin1() );
528 //qDebug() << "\tVariantBinding typeName=" << valImp->variant().typeName() << "type=" << valImp->variant().type() << "userType=" << valImp->variant().userType() << " variant=" << valImp->variant();
619 KJS::JSValue *SlotBinding::callAsFunction( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args )
648 return KJS::throwError(exec, KJS::GeneralError, i18n("No such method '%1'.", m_memberName.constData()));
649 //return KJSEmbed::throwError(exec, i18n("Call to '%1' failed.").arg(m_memberName.constData()));
677 return KJS::throwError(exec, KJS::GeneralError, i18n("Call to method '%1' failed, unable to get argument %2: %3", m_memberName.constData(), idx, errorText));
720 return KJS::throwError(exec, KJS::GeneralError, i18n("Call to '%1' failed.", m_memberName.constData()));
726 : KJS::InternalFunctionImp(static_cast<KJS::FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()),
735 KJS::JSObject* KJSEmbed::createQObject(KJS::ExecState *exec, QObject *value, KJSEmbed::ObjectBinding::Ownership owner)
821 KJSEmbed::QObjectBinding *parentImp = KJSEmbed::extractBindingImp<KJSEmbed::QObjectBinding>(exec, parentObject);
823 parentImp->setAccess( imp->access() ); // inherit access from child since we don't know the access-level of the parent here :-(
848 KJSEmbed::QObjectBinding *childImp = KJSEmbed::extractBindingImp<KJSEmbed::QObjectBinding>(exec, childObject);
QVariant KJSEMBED_EXPORT convertToVariant(KJS::ExecState *exec, KJS::JSValue *value)
Convert a KJS::JSValue into a QVariant object.
Definition: variant_binding.cpp:253
bool canConvert(Type t) const
static KJS::JSValue * propertyGetter(KJS::ExecState *exec, KJS::JSObject *, const KJS::Identifier &name, const KJS::PropertySlot &)
Callback used to get properties.
Definition: qobject_binding.cpp:297
int indexOfSignal(const char *signal) const
Definition: qobject_binding.h:79
void put(KJS::ExecState *exec, const KJS::Identifier &propertyName, KJS::JSValue *value, int attr=KJS::None)
Set the value value of the property propertyName .
Definition: qobject_binding.cpp:322
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
QStringList KJSEMBED_EXPORT convertArrayToStringList(KJS::ExecState *exec, KJS::JSValue *value)
Convert a KJS::JSValue inot a QStringList.
Definition: variant_binding.cpp:199
KJS::JSValue * callConnect(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: qobject_binding.cpp:113
void addFilter(QEvent::Type t)
Adds an event type to those we forward to JS.
Definition: eventproxy.cpp:52
static void publish(KJS::ExecState *exec, KJS::JSObject *object, const Method *methods)
Publishes an array of Methods to an object.
Definition: static_binding.cpp:60
KJS::UString className() const
Definition: qobject_binding.cpp:387
Provide access to the child QObject's the QObject has.
Definition: qobject_binding.h:117
QMap< QString, QVariant > KJSEMBED_EXPORT convertArrayToMap(KJS::ExecState *exec, KJS::JSValue *value)
Convert a KJS::JSValue that contains an associative array into a QMap.
Definition: variant_binding.cpp:153
int keyCount() const
Publish properties that don't have Q_SCRIPTABLE defined.
Definition: qobject_binding.h:112
bool isEnumType() const
const char * typeName() const
const QMetaObject * superClass() const
bool isWritable() const
Definition: pointer.h:42
virtual ~QObjectBinding()
Definition: qobject_binding.cpp:253
Filters events for a QObject and forwards them to a JS handler.
Definition: eventproxy.h:44
A binding method that is used in VariantBinding and ObjectBinding.
Definition: static_binding.h:39
END_QOBJECT_METHOD START_METHOD_LUT(QObjectFactory)
Definition: qobject_binding.cpp:856
bool validSignal(const QMetaMethod &method, QObjectBinding::AccessFlags accessflags)
Definition: qobject_binding.cpp:80
virtual const QMetaObject * metaObject() const
KJS::JSObject * construct(KJS::ExecState *exec, const KJS::List &args)
Calls the callback that will in turn create a new instance of this object with the arguments passed i...
Definition: static_binding.cpp:79
T value() const
QList< QByteArray > parameterTypes() const
QString & remove(int position, int n)
void remove(QObject *object)
int type(const char *typeName)
Definition: pointer.h:31
Access access() const
int size() const
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
Publish signals that don't have Q_SCRIPTABLE defined.
Definition: qobject_binding.h:105
Definition: object_binding.h:88
bool isEmpty() const
bool isEventHandler(const KJS::Identifier &name) const
Returns true iff the specified name is the identifier for an event handler.
Definition: jseventmapper.cpp:274
KJSEMBED_EXPORT KJS::JSObject * createQObject(KJS::ExecState *exec, QObject *value, KJSEmbed::ObjectBinding::Ownership owner=KJSEmbed::ObjectBinding::JSOwned)
Returns a binding object for the specified QObject.
Definition: qobject_binding.cpp:735
QString number(int n, int base)
#define START_QOBJECT_METHOD(METHODNAME, TYPE)
A simple pointer syle method.
Definition: qobject_binding.h:45
uint toUInt(bool *ok) const
QVariant property(const char *name) const
bool isNull() const
#define END_QOBJECT_METHOD
End a variant method started by START_QOBJECT_METHOD.
Definition: qobject_binding.h:60
void watchObject(QObject *object)
Add the QObject object to the internal QObjectCleanupHandler to watch the lifetime of the QObject to ...
Definition: qobject_binding.cpp:276
bool inherits(const char *className) const
Type nameToType(const char *name)
QList< QVariant > KJSEMBED_EXPORT convertArrayToList(KJS::ExecState *exec, KJS::JSValue *value)
Convert a KJS::JSValue into a QList.
Definition: variant_binding.cpp:169
int value(int index) const
bool isEmpty() const
bool validSlot(const QMetaMethod &method, QObjectBinding::AccessFlags accessflags)
Definition: qobject_binding.cpp:58
int methodCount() const
const char * constData() const
SlotBinding(KJS::ExecState *exec, const QMetaMethod &memberName)
Definition: qobject_binding.cpp:725
QByteArray & replace(int pos, int len, const char *after)
const char * signature() const
void setOwnership(Ownership owner)
Definition: object_binding.cpp:70
KJS::UString toString(KJS::ExecState *exec) const
Definition: qobject_binding.cpp:392
Publish slots that have Q_SCRIPTABLE defined.
Definition: qobject_binding.h:97
void setAccess(AccessFlags access)
Set the defined Access flags to access .
Definition: qobject_binding.cpp:317
Definition: pointer.h:103
static void publishQObject(KJS::ExecState *exec, KJS::JSObject *target, QObject *object)
Definition: qobject_binding.cpp:174
PointerBase * getArg(KJS::ExecState *exec, const QList< QByteArray > &types, const KJS::List &args, int idx, QString &errorText)
Definition: qobject_binding.cpp:401
QMetaEnum enumerator(int index) const
Definition: qobject_binding.h:194
void setParent(QObject *parent)
int indexOfSlot(const char *slot) const
const char * className() const
int indexOfProperty(const char *name) const
int enumeratorCount() const
QList< QByteArray > parameterNames() const
Definition: slotproxy.h:41
Definition: pointer.h:73
QObject * add(QObject *object)
static KJS::JSObject * bind(KJS::ExecState *exec, const QString &className, PointerBase &objPtr)
Definition: static_binding.cpp:130
Publish protected signals.
Definition: qobject_binding.h:107
Definition: variant_binding.cpp:130
const char * typeName() const
Publish slots that don't have Q_SCRIPTABLE defined.
Definition: qobject_binding.h:98
QString left(int n) const
KJSEMBED_EXPORT KJS::JSValue * convertToValue(KJS::ExecState *exec, const QVariant &value)
Convert a QVariant to a KJS::JSValue.
Definition: variant_binding.cpp:298
Definition: variant_binding.cpp:130
bool isValid() const
bool setProperty(const char *name, const QVariant &value)
bool getOwnPropertySlot(KJS::ExecState *exec, const KJS::Identifier &propertyName, KJS::PropertySlot &slot)
Called to ask if we have a callback for the named property.
Definition: qobject_binding.cpp:281
bool canPut(KJS::ExecState *exec, const KJS::Identifier &propertyName) const
Definition: qobject_binding.cpp:371
Type type() const
virtual void * voidStar()=0
QObjectBinding(KJS::ExecState *exec, QObject *object)
Definition: qobject_binding.cpp:229
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
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
KJS::JSValue * callAsFunction(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: qobject_binding.cpp:619
QObject * parent() const
Publish properties that have Q_SCRIPTABLE defined.
Definition: qobject_binding.h:111
bool isScriptable(const QObject *object) const
void removeFilter(QEvent::Type t)
Removes an event type from those we forward to JS.
Definition: eventproxy.cpp:69
bool convert(Type t)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
JSObject * throwError(ExecState *e, ErrorType t, const QString &m)
Definition: binding_support.h:241
QVariant KJSEMBED_EXPORT extractVariant(KJS::ExecState *exec, KJS::JSValue *value)
Extracts a QVariant from a KJS::JSValue if the conversion fails a QVariant::Null is returned...
Definition: variant_binding.cpp:407
QMetaMethod method(int index) const
const char * key(int index) const
bool validProperty(const QMetaProperty &property, QObjectBinding::AccessFlags accessflags)
Definition: qobject_binding.cpp:102
QMetaProperty property(int index) const
QByteArray extractMemberName(const QMetaMethod &member)
Definition: qobject_binding.cpp:168
Publish signals that have Q_SCRIPTABLE defined.
Definition: qobject_binding.h:104
QByteArray toUtf8() const
T findChild(const QString &name) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.