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()));
174void 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]) );
281bool 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());
322void 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()));
401PointerBase *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();
619KJS::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()),
735KJS::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);
Filters events for a QObject and forwards them to a JS handler.
Definition: eventproxy.h:45
void addFilter(QEvent::Type t)
Adds an event type to those we forward to JS.
Definition: eventproxy.cpp:52
void removeFilter(QEvent::Type t)
Removes an event type from those we forward to JS.
Definition: eventproxy.cpp:69
Definition: object_binding.h:89
void setOwnership(Ownership owner)
Definition: object_binding.cpp:70
Definition: qobject_binding.h:80
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
bool canPut(KJS::ExecState *exec, const KJS::Identifier &propertyName) const
Definition: qobject_binding.cpp:371
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
KJS::UString className() const
Definition: qobject_binding.cpp:387
QObjectBinding(KJS::ExecState *exec, QObject *object)
Definition: qobject_binding.cpp:229
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
@ NonScriptableSignals
Publish signals that don't have Q_SCRIPTABLE defined.
Definition: qobject_binding.h:105
@ ChildObjects
Provide access to the child QObject's the QObject has.
Definition: qobject_binding.h:117
@ NonScriptableSlots
Publish slots that don't have Q_SCRIPTABLE defined.
Definition: qobject_binding.h:98
@ ScriptableProperties
Publish properties that have Q_SCRIPTABLE defined.
Definition: qobject_binding.h:111
@ NonScriptableProperties
Publish properties that don't have Q_SCRIPTABLE defined.
Definition: qobject_binding.h:112
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
void setAccess(AccessFlags access)
Set the defined Access flags to access .
Definition: qobject_binding.cpp:317
virtual ~QObjectBinding()
Definition: qobject_binding.cpp:253
static void publishQObject(KJS::ExecState *exec, KJS::JSObject *target, QObject *object)
Definition: qobject_binding.cpp:174
KJS::UString toString(KJS::ExecState *exec) const
Definition: qobject_binding.cpp:392
Definition: qobject_binding.h:195
SlotBinding(KJS::ExecState *exec, const QMetaMethod &memberName)
Definition: qobject_binding.cpp:725
KJS::JSValue * callAsFunction(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: qobject_binding.cpp:619
Definition: slotproxy.h:42
A binding method that is used in VariantBinding and ObjectBinding.
Definition: static_binding.h:40
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::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
static KJS::JSObject * bind(KJS::ExecState *exec, const QString &className, PointerBase &objPtr)
Definition: static_binding.cpp:130
if(file->open((QIODevice::OpenModeFlag) KJSEmbed::extractInt(exec, args, 0)))
Definition: fileio.cpp:64
Definition: application.h:33
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
QVariant KJSEMBED_EXPORT convertToVariant(KJS::ExecState *exec, KJS::JSValue *value)
Convert a KJS::JSValue into a QVariant object.
Definition: variant_binding.cpp:253
QStringList KJSEMBED_EXPORT convertArrayToStringList(KJS::ExecState *exec, KJS::JSValue *value)
Convert a KJS::JSValue inot a QStringList.
Definition: variant_binding.cpp:199
KJSEMBED_EXPORT KJS::JSValue * convertToValue(KJS::ExecState *exec, const QVariant &value)
Convert a QVariant to a KJS::JSValue.
Definition: variant_binding.cpp:298
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
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
QList< QVariant > KJSEMBED_EXPORT convertArrayToList(KJS::ExecState *exec, KJS::JSValue *value)
Convert a KJS::JSValue into a QList.
Definition: variant_binding.cpp:169
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
JSObject * throwError(ExecState *e, ErrorType t, const QString &m)
Definition: binding_support.h:241
bool validSignal(const QMetaMethod &method, QObjectBinding::AccessFlags accessflags)
Definition: qobject_binding.cpp:80
QByteArray extractMemberName(const QMetaMethod &member)
Definition: qobject_binding.cpp:168
bool validProperty(const QMetaProperty &property, QObjectBinding::AccessFlags accessflags)
Definition: qobject_binding.cpp:102
KJS::JSValue * callConnect(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
Definition: qobject_binding.cpp:113
PointerBase * getArg(KJS::ExecState *exec, const QList< QByteArray > &types, const KJS::List &args, int idx, QString &errorText)
Definition: qobject_binding.cpp:401
bool validSlot(const QMetaMethod &method, QObjectBinding::AccessFlags accessflags)
Definition: qobject_binding.cpp:58
#define START_QOBJECT_METHOD(METHODNAME, TYPE)
A simple pointer syle method.
Definition: qobject_binding.h:45
#define END_QOBJECT_METHOD
End a variant method started by START_QOBJECT_METHOD.
Definition: qobject_binding.h:60
Definition: pointer.h:104
Definition: pointer.h:32
virtual void * voidStar()=0
Definition: pointer.h:43
Definition: pointer.h:74
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.