Qt 4.8
Classes | Public Types | Public Functions | Public Variables | Static Public Variables | List of all members
QDeclarativeCompiledBindingsPrivate Class Reference
Inheritance diagram for QDeclarativeCompiledBindingsPrivate:
QObjectPrivate QObjectData

Classes

struct  Binding
 

Public Types

typedef QDeclarativeNotifierEndpoint Subscription
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Public Functions

void disconnectAll ()
 
void disconnectOne (Binding *bindingToDisconnect)
 
void findgeneric (Register *output, int subIdx, QDeclarativeContextData *context, const QScriptDeclarativeClass::Identifier &name, bool isTerminal)
 
QDeclarativePropertyCache::Datafindproperty (QObject *obj, const QScriptDeclarativeClass::Identifier &name, QDeclarativeEnginePrivate *enginePriv, QDeclarativePropertyCache::Data &local)
 
bool findproperty (QObject *obj, Register *output, QDeclarativeEnginePrivate *enginePriv, int subIdx, const QScriptDeclarativeClass::Identifier &name, bool isTerminal)
 
void init ()
 
 QDeclarativeCompiledBindingsPrivate ()
 
void run (Binding *, QDeclarativePropertyPrivate::WriteFlags flags)
 
void run (int instr, QDeclarativeContextData *context, QDeclarativeDelayedError *error, QObject *scope, QObject *output, QDeclarativePropertyPrivate::WriteFlags storeFlags)
 
void subscribe (QObject *o, int notifyIndex, int subIndex)
 
void subscribeId (QDeclarativeContextData *p, int idIndex, int subIndex)
 
virtual ~QDeclarativeCompiledBindingsPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

QDeclarativeRefCountdataRef
 
QScriptDeclarativeClass::PersistentIdentifieridentifiers
 
Bindingm_bindings
 
bool m_bindingsDisconnected
 
quint32m_signalTable
 
const char * programData
 
Subscriptionsubscriptions
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Static Public Variables

static int methodCount = -1
 

Additional Inherited Members

- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Detailed Description

Definition at line 204 of file qdeclarativecompiledbindings.cpp.

Typedefs

◆ Subscription

Definition at line 232 of file qdeclarativecompiledbindings.cpp.

Constructors and Destructors

◆ QDeclarativeCompiledBindingsPrivate()

QDeclarativeCompiledBindingsPrivate::QDeclarativeCompiledBindingsPrivate ( )

◆ ~QDeclarativeCompiledBindingsPrivate()

QDeclarativeCompiledBindingsPrivate::~QDeclarativeCompiledBindingsPrivate ( )
virtual

Definition at line 279 of file qdeclarativecompiledbindings.cpp.

280 {
281  delete [] subscriptions; subscriptions = 0;
282  delete [] identifiers; identifiers = 0;
283  if (dataRef) {
284  dataRef->release();
285  dataRef = 0;
286  }
287 }
QScriptDeclarativeClass::PersistentIdentifier * identifiers

Functions

◆ disconnectAll()

void QDeclarativeCompiledBindingsPrivate::disconnectAll ( )
inline

Definition at line 741 of file qdeclarativecompiledbindings.cpp.

742 {
743  // This gets called multiple times in QDeclarativeData::disconnectNotifiers(), avoid unneeded
744  // work for all but the first call.
746  return;
747 
748  // We disconnect all subscriptions, so we can call disconnect() unconditionally if there is at
749  // least one connection
750  Program *program = (Program *)programData;
751  for (int subIndex = 0; subIndex < program->subscriptions; ++subIndex) {
752  Subscription * const sub = (subscriptions + subIndex);
753  if (sub->isConnected())
754  sub->disconnect();
755  }
756  m_bindingsDisconnected = true;
757 }

◆ disconnectOne()

void QDeclarativeCompiledBindingsPrivate::disconnectOne ( QDeclarativeCompiledBindingsPrivate::Binding bindingToDisconnect)
inline

Definition at line 759 of file qdeclarativecompiledbindings.cpp.

761 {
762  // We iterate over the signal table to find all subscriptions for this binding. This is slowish,
763  // but disconnectOne() is only called when overwriting a binding, which is quite rare.
764  Program *program = (Program *)programData;
765  for (int subIndex = 0; subIndex < program->subscriptions; ++subIndex) {
766  Subscription * const sub = (subscriptions + subIndex);
767  quint32 *reeval = m_signalTable + m_signalTable[subIndex];
768  quint32 bindingCount = *reeval;
769  ++reeval;
770  for (quint32 bindingIndex = 0; bindingIndex < bindingCount; ++bindingIndex) {
771  Binding * const binding = m_bindings + reeval[bindingIndex];
772  if (binding == bindingToDisconnect)
773  sub->deref();
774  }
775  }
776 }
The Binding element allows arbitrary property bindings to be created.
unsigned int quint32
Definition: qglobal.h:938

◆ findgeneric()

void QDeclarativeCompiledBindingsPrivate::findgeneric ( Register *  output,
int  subIdx,
QDeclarativeContextData context,
const QScriptDeclarativeClass::Identifier name,
bool  isTerminal 
)

Definition at line 941 of file qdeclarativecompiledbindings.cpp.

946 {
948 
949  while (context) {
950 
951  int contextPropertyIndex = context->propertyNames?context->propertyNames->value(name):-1;
952 
953 
954  if (contextPropertyIndex != -1) {
955 
956  if (contextPropertyIndex < context->idValueCount) {
957  output->setQObject(context->idValues[contextPropertyIndex]);
958  output->settype(QMetaType::QObjectStar);
959 
960  if (subIdx != -1)
961  subscribeId(context, contextPropertyIndex, subIdx);
962 
963  } else {
965  const QVariant &value = cp->propertyValues.at(contextPropertyIndex);
966 
967  if (isTerminal) {
968  new (output->typeDataPtr()) QVariant(value);
969  output->settype(qMetaTypeId<QVariant>());
970  } else {
971  bool ok;
972  output->setQObject(variantToQObject(value, &ok));
973  if (!ok) { output->setUndefined(); }
974  else { output->settype(QMetaType::QObjectStar); }
975  return;
976  }
977 
978  if (subIdx != -1)
979  subscribe(context->asQDeclarativeContext(), contextPropertyIndex + cp->notifyIndex, subIdx);
980 
981 
982  }
983 
984  return;
985  }
986 
987  if (QObject *root = context->contextObject) {
988 
989  if (findproperty(root, output, enginePriv, subIdx, name, isTerminal))
990  return;
991 
992  }
993 
994  context = context->parent;
995  }
996 
997  output->setUndefined();
998 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDeclarativeEngine * engine
void subscribe(QObject *o, int notifyIndex, int subIndex)
void subscribeId(QDeclarativeContextData *p, int idIndex, int subIndex)
QDeclarativeContextData * parent
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
QDeclarativeContextPrivate * asQDeclarativeContextPrivate()
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QObject * variantToQObject(const QVariant &value, bool *ok)
QDeclarativePropertyCache::Data * findproperty(QObject *obj, const QScriptDeclarativeClass::Identifier &name, QDeclarativeEnginePrivate *enginePriv, QDeclarativePropertyCache::Data &local)
QDeclarativeIntegerCache * propertyNames
QDeclarativeContext * asQDeclarativeContext()

◆ findproperty() [1/2]

QDeclarativePropertyCache::Data* QDeclarativeCompiledBindingsPrivate::findproperty ( QObject obj,
const QScriptDeclarativeClass::Identifier name,
QDeclarativeEnginePrivate enginePriv,
QDeclarativePropertyCache::Data local 
)

◆ findproperty() [2/2]

bool QDeclarativeCompiledBindingsPrivate::findproperty ( QObject obj,
Register *  output,
QDeclarativeEnginePrivate enginePriv,
int  subIdx,
const QScriptDeclarativeClass::Identifier name,
bool  isTerminal 
)

Definition at line 868 of file qdeclarativecompiledbindings.cpp.

872 {
873  if (!obj) {
874  output->setUndefined();
875  return false;
876  }
877 
881 
882  if (property) {
883  if (subIdx != -1)
884  subscribe(obj, property->notifyIndex, subIdx);
885 
887  void *args[] = { output->typeDataPtr(), 0 };
889  output->settype(QMetaType::QObjectStar);
890  } else if (property->propType == qMetaTypeId<QVariant>()) {
891  QVariant v;
892  void *args[] = { &v, 0 };
894 
895  if (isTerminal) {
896  new (output->typeDataPtr()) QVariant(v);
897  output->settype(qMetaTypeId<QVariant>());
898  } else {
899  bool ok;
900  output->setQObject(variantToQObject(v, &ok));
901  if (!ok)
902  output->setUndefined();
903  else
904  output->settype(QMetaType::QObjectStar);
905  }
906 
907  } else {
908  if (!isTerminal) {
909  output->setUndefined();
910  } else if (property->propType == QMetaType::QReal) {
911  void *args[] = { output->typeDataPtr(), 0 };
913  output->settype(QMetaType::QReal);
914  } else if (property->propType == QMetaType::Int) {
915  void *args[] = { output->typeDataPtr(), 0 };
917  output->settype(QMetaType::Int);
918  } else if (property->propType == QMetaType::Bool) {
919  void *args[] = { output->typeDataPtr(), 0 };
921  output->settype(QMetaType::Bool);
922  } else if (property->propType == QMetaType::QString) {
923  new (output->typeDataPtr()) QString();
924  void *args[] = { output->typeDataPtr(), 0 };
926  output->settype(QMetaType::QString);
927  } else {
928  new (output->typeDataPtr())
929  QVariant(obj->metaObject()->property(property->coreIndex).read(obj));
930  output->settype(qMetaTypeId<QVariant>());
931  }
932  }
933 
934  return true;
935  } else {
936  output->setUndefined();
937  return false;
938  }
939 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static int metacall(QObject *, Call, int, void **)
void subscribe(QObject *o, int notifyIndex, int subIndex)
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
const char * name
Data * property(const QScriptDeclarativeClass::Identifier &id) const
static QObject * variantToQObject(const QVariant &value, bool *ok)
const char * property
Definition: qwizard.cpp:138
QVariant read(const QObject *obj) const
Reads the property&#39;s value from the given object.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

◆ init()

void QDeclarativeCompiledBindingsPrivate::init ( )

Definition at line 1000 of file qdeclarativecompiledbindings.cpp.

1001 {
1002  Program *program = (Program *)programData;
1003  if (program->subscriptions)
1005  if (program->identifiers)
1006  identifiers = new QScriptDeclarativeClass::PersistentIdentifier[program->identifiers];
1007 
1008  m_signalTable = (quint32 *)(program->data() + program->signalTableOffset);
1010 }
QScriptDeclarativeClass::PersistentIdentifier * identifiers
unsigned int quint32
Definition: qglobal.h:938

◆ run() [1/2]

void QDeclarativeCompiledBindingsPrivate::run ( Binding binding,
QDeclarativePropertyPrivate::WriteFlags  flags 
)

Definition at line 386 of file qdeclarativecompiledbindings.cpp.

387 {
389 
390  if (!binding->enabled)
391  return;
392 
393  QDeclarativeContextData *context = q->QDeclarativeAbstractExpression::context();
394  if (!context || !context->isValid())
395  return;
396 
397  if (binding->updating) {
398  QString name;
399  if (binding->property & 0xFFFF0000) {
401 
402  QDeclarativeValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
403  Q_ASSERT(vt);
404 
405  name = QLatin1String(binding->target->metaObject()->property(binding->property & 0xFFFF).name());
406  name.append(QLatin1String("."));
407  name.append(QLatin1String(vt->metaObject()->property(binding->property >> 24).name()));
408  } else {
409  name = QLatin1String(binding->target->metaObject()->property(binding->property).name());
410  }
411  qmlInfo(binding->target) << QCoreApplication::translate("QDeclarativeCompiledBindings", "Binding loop detected for property \"%1\"").arg(name);
412  return;
413  }
414 
415  binding->updating = true;
416  if (binding->property & 0xFFFF0000) {
418 
419  QDeclarativeValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
420  Q_ASSERT(vt);
421  vt->read(binding->target, binding->property & 0xFFFF);
422 
423  QObject *target = vt;
424  run(binding->index, context, binding, binding->scope, target, flags);
425 
426  vt->write(binding->target, binding->property & 0xFFFF, flags);
427  } else {
428  run(binding->index, context, binding, binding->scope, binding->target, flags);
429  }
430  binding->updating = false;
431 }
QDeclarativeEngine * engine
void run(Binding *, QDeclarativePropertyPrivate::WriteFlags flags)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags flags)=0
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
#define Q_Q(Class)
Definition: qglobal.h:2483
const char * name
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QString & append(QChar c)
Definition: qstring.cpp:1777
const char * name() const
Returns this property&#39;s name.
QDeclarativeValueTypeFactory valueTypes
QDeclarativeInfo qmlInfo(const QObject *me)
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
virtual void read(QObject *, int)=0

◆ run() [2/2]

void QDeclarativeCompiledBindingsPrivate::run ( int  instr,
QDeclarativeContextData context,
QDeclarativeDelayedError error,
QObject scope,
QObject output,
QDeclarativePropertyPrivate::WriteFlags  storeFlags 
)

Definition at line 1180 of file qdeclarativecompiledbindings.cpp.

1183 {
1185 
1186  error->removeError();
1187 
1188  Register registers[32];
1189 
1191  Program *program = (Program *)programData;
1192  const Instr *instr = program->instructions();
1193  instr += instrIndex;
1194  const char *data = program->data();
1195 
1196 #ifdef QML_THREADED_INTERPRETER
1197  static void *decode_instr[] = {
1199  };
1200 
1201  if (!program->compiled) {
1202  program->compiled = true;
1203  const Instr *inop = program->instructions();
1204  for (int i = 0; i < program->instructionCount; ++i) {
1205  Instr *op = (Instr *) inop++;
1206  op->common.code = decode_instr[op->common.type];
1207  }
1208  }
1209 
1210  goto *instr->common.code;
1211 #else
1212  // return;
1213 
1214 #ifdef COMPILEDBINDINGS_DEBUG
1215  qWarning().nospace() << "Begin binding run";
1216 #endif
1217 
1218  while (instr) {
1219  switch (instr->common.type) {
1220 
1221 #ifdef COMPILEDBINDINGS_DEBUG
1222  dumpInstruction(instr);
1223 #endif
1224 
1225 #endif
1226 
1227  QML_BEGIN_INSTR(Noop)
1228  QML_END_INSTR(Noop)
1229 
1230  QML_BEGIN_INSTR(BindingId)
1231  QML_END_INSTR(BindingId)
1232 
1233  QML_BEGIN_INSTR(SubscribeId)
1234  subscribeId(context, instr->subscribe.index, instr->subscribe.offset);
1235  QML_END_INSTR(SubscribeId)
1236 
1237  QML_BEGIN_INSTR(Subscribe)
1238  {
1239  QObject *o = 0;
1240  const Register &object = registers[instr->subscribe.reg];
1241  if (!object.isUndefined()) o = object.getQObject();
1242  subscribe(o, instr->subscribe.index, instr->subscribe.offset);
1243  }
1244  QML_END_INSTR(Subscribe)
1245 
1246  QML_BEGIN_INSTR(FetchAndSubscribe)
1247  {
1248  const Register &input = registers[instr->fetchAndSubscribe.objectReg];
1249  Register &output = registers[instr->fetchAndSubscribe.output];
1250 
1251  if (input.isUndefined()) {
1252  throwException(instr->fetchAndSubscribe.exceptionId, error, program, context);
1253  return;
1254  }
1255 
1256  QObject *object = input.getQObject();
1257  if (!object) {
1258  output.setUndefined();
1259  } else {
1260  int subIdx = instr->fetchAndSubscribe.subscription;
1262  if (subIdx != -1) {
1263  sub = (subscriptions + subIdx);
1264  sub->target = q;
1265  sub->targetMethod = methodCount + subIdx;
1266  }
1267  fastProperties()->accessor(instr->fetchAndSubscribe.function)(object, output.typeDataPtr(), sub);
1268  }
1269  }
1270  QML_END_INSTR(FetchAndSubscribe)
1271 
1272  QML_BEGIN_INSTR(LoadId)
1273  registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
1274  QML_END_INSTR(LoadId)
1275 
1276  QML_BEGIN_INSTR(LoadScope)
1277  registers[instr->load.reg].setQObject(scope);
1278  QML_END_INSTR(LoadScope)
1279 
1280  QML_BEGIN_INSTR(LoadRoot)
1281  registers[instr->load.reg].setQObject(context->contextObject);
1282  QML_END_INSTR(LoadRoot)
1283 
1284  QML_BEGIN_INSTR(LoadAttached)
1285  {
1286  const Register &input = registers[instr->attached.reg];
1287  Register &output = registers[instr->attached.output];
1288  if (input.isUndefined()) {
1289  throwException(instr->attached.exceptionId, error, program, context);
1290  return;
1291  }
1292 
1293  QObject *object = registers[instr->attached.reg].getQObject();
1294  if (!object) {
1295  output.setUndefined();
1296  } else {
1297  QObject *attached =
1298  qmlAttachedPropertiesObjectById(instr->attached.id,
1299  registers[instr->attached.reg].getQObject(),
1300  true);
1301  Q_ASSERT(attached);
1302  output.setQObject(attached);
1303  }
1304  }
1305  QML_END_INSTR(LoadAttached)
1306 
1307  QML_BEGIN_INSTR(ConvertIntToReal)
1308  {
1309  const Register &input = registers[instr->unaryop.src];
1310  Register &output = registers[instr->unaryop.output];
1311  if (input.isUndefined()) output.setUndefined();
1312  else output.setqreal(qreal(input.getint()));
1313  }
1314  QML_END_INSTR(ConvertIntToReal)
1315 
1316  QML_BEGIN_INSTR(ConvertRealToInt)
1317  {
1318  const Register &input = registers[instr->unaryop.src];
1319  Register &output = registers[instr->unaryop.output];
1320  if (input.isUndefined()) output.setUndefined();
1321  else output.setint(qRound(input.getqreal()));
1322  }
1323  QML_END_INSTR(ConvertRealToInt)
1324 
1325  QML_BEGIN_INSTR(Real)
1326  registers[instr->real_value.reg].setqreal(instr->real_value.value);
1327  QML_END_INSTR(Real)
1328 
1329  QML_BEGIN_INSTR(Int)
1330  registers[instr->int_value.reg].setint(instr->int_value.value);
1331  QML_END_INSTR(Int)
1332 
1333  QML_BEGIN_INSTR(Bool)
1334  registers[instr->bool_value.reg].setbool(instr->bool_value.value);
1335  QML_END_INSTR(Bool)
1336 
1338  {
1339  Register &output = registers[instr->string_value.reg];
1340  new (output.getstringptr())
1341  QString((QChar *)(data + instr->string_value.offset), instr->string_value.length);
1342  output.settype(QMetaType::QString);
1343  }
1345 
1346  QML_BEGIN_INSTR(AddReal)
1347  {
1348  const Register &lhs = registers[instr->binaryop.src1];
1349  const Register &rhs = registers[instr->binaryop.src2];
1350  Register &output = registers[instr->binaryop.output];
1351  if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1352  else output.setqreal(lhs.getqreal() + rhs.getqreal());
1353  }
1354  QML_END_INSTR(AddReal)
1355 
1356  QML_BEGIN_INSTR(AddInt)
1357  {
1358  const Register &lhs = registers[instr->binaryop.src1];
1359  const Register &rhs = registers[instr->binaryop.src2];
1360  Register &output = registers[instr->binaryop.output];
1361  if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1362  else output.setint(lhs.getint() + rhs.getint());
1363  }
1364  QML_END_INSTR(AddInt)
1365 
1366  QML_BEGIN_INSTR(AddString)
1367  {
1368  const Register &lhs = registers[instr->binaryop.src1];
1369  const Register &rhs = registers[instr->binaryop.src2];
1370  Register &output = registers[instr->binaryop.output];
1371  if (lhs.isUndefined() && rhs.isUndefined()) { output.setNaN(); }
1372  else {
1373  if (lhs.isUndefined())
1374  new (output.getstringptr())
1375  QString(QLatin1String("undefined") + *registers[instr->binaryop.src2].getstringptr());
1376  else if (rhs.isUndefined())
1377  new (output.getstringptr())
1378  QString(*registers[instr->binaryop.src1].getstringptr() + QLatin1String("undefined"));
1379  else
1380  new (output.getstringptr())
1381  QString(*registers[instr->binaryop.src1].getstringptr() +
1382  *registers[instr->binaryop.src2].getstringptr());
1383  output.settype(QMetaType::QString);
1384  }
1385  }
1386  QML_END_INSTR(AddString)
1387 
1388  QML_BEGIN_INSTR(MinusReal)
1389  {
1390  const Register &lhs = registers[instr->binaryop.src1];
1391  const Register &rhs = registers[instr->binaryop.src2];
1392  Register &output = registers[instr->binaryop.output];
1393  if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1394  else output.setqreal(lhs.getqreal() - rhs.getqreal());
1395  }
1396  QML_END_INSTR(MinusReal)
1397 
1398  QML_BEGIN_INSTR(MinusInt)
1399  {
1400  const Register &lhs = registers[instr->binaryop.src1];
1401  const Register &rhs = registers[instr->binaryop.src2];
1402  Register &output = registers[instr->binaryop.output];
1403  if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1404  else output.setint(lhs.getint() - rhs.getint());
1405  }
1406  QML_END_INSTR(MinusInt)
1407 
1408  QML_BEGIN_INSTR(CompareReal)
1409  {
1410  const Register &lhs = registers[instr->binaryop.src1];
1411  const Register &rhs = registers[instr->binaryop.src2];
1412  Register &output = registers[instr->binaryop.output];
1413  if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
1414  else output.setbool(lhs.getqreal() == rhs.getqreal());
1415  }
1416  QML_END_INSTR(CompareReal)
1417 
1418  QML_BEGIN_INSTR(CompareString)
1419  {
1420  const Register &lhs = registers[instr->binaryop.src1];
1421  const Register &rhs = registers[instr->binaryop.src2];
1422  Register &output = registers[instr->binaryop.output];
1423  if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
1424  else output.setbool(*lhs.getstringptr() == *rhs.getstringptr());
1425  }
1426  QML_END_INSTR(CompareString)
1427 
1428  QML_BEGIN_INSTR(NotCompareReal)
1429  {
1430  const Register &lhs = registers[instr->binaryop.src1];
1431  const Register &rhs = registers[instr->binaryop.src2];
1432  Register &output = registers[instr->binaryop.output];
1433  if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
1434  else output.setbool(lhs.getqreal() != rhs.getqreal());
1435  }
1436  QML_END_INSTR(NotCompareReal)
1437 
1438  QML_BEGIN_INSTR(NotCompareString)
1439  {
1440  const Register &lhs = registers[instr->binaryop.src1];
1441  const Register &rhs = registers[instr->binaryop.src2];
1442  Register &output = registers[instr->binaryop.output];
1443  if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
1444  else output.setbool(*lhs.getstringptr() != *rhs.getstringptr());
1445  }
1446  QML_END_INSTR(NotCompareString)
1447 
1448  QML_BEGIN_INSTR(GreaterThanReal)
1449  {
1450  const Register &lhs = registers[instr->binaryop.src1];
1451  const Register &rhs = registers[instr->binaryop.src2];
1452  Register &output = registers[instr->binaryop.output];
1453  if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(false);
1454  else output.setbool(lhs.getqreal() > rhs.getqreal());
1455  }
1456  QML_END_INSTR(GreaterThanReal)
1457 
1458  QML_BEGIN_INSTR(MaxReal)
1459  {
1460  const Register &lhs = registers[instr->binaryop.src1];
1461  const Register &rhs = registers[instr->binaryop.src2];
1462  Register &output = registers[instr->binaryop.output];
1463  if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1464  else output.setqreal(qMax(lhs.getqreal(), rhs.getqreal()));
1465  }
1466  QML_END_INSTR(MaxReal)
1467 
1468  QML_BEGIN_INSTR(MinReal)
1469  {
1470  const Register &lhs = registers[instr->binaryop.src1];
1471  const Register &rhs = registers[instr->binaryop.src2];
1472  Register &output = registers[instr->binaryop.output];
1473  if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1474  else output.setqreal(qMin(lhs.getqreal(), rhs.getqreal()));
1475  }
1476  QML_END_INSTR(MinReal)
1477 
1478  QML_BEGIN_INSTR(NewString)
1479  {
1480  Register &output = registers[instr->construct.reg];
1481  new (output.getstringptr()) QString;
1482  output.settype(QMetaType::QString);
1483  }
1484  QML_END_INSTR(NewString)
1485 
1486  QML_BEGIN_INSTR(NewUrl)
1487  {
1488  Register &output = registers[instr->construct.reg];
1489  new (output.geturlptr()) QUrl;
1490  output.settype(QMetaType::QUrl);
1491  }
1492  QML_END_INSTR(NewUrl)
1493 
1494  QML_BEGIN_INSTR(CleanupString)
1495  registers[instr->cleanup.reg].getstringptr()->~QString();
1496 #ifdef REGISTER_CLEANUP_DEBUG
1497  registers[instr->cleanup.reg].setUndefined();
1498 #endif
1499  QML_END_INSTR(CleanupString)
1500 
1501  QML_BEGIN_INSTR(CleanupUrl)
1502  registers[instr->cleanup.reg].geturlptr()->~QUrl();
1503 #ifdef REGISTER_CLEANUP_DEBUG
1504  registers[instr->cleanup.reg].setUndefined();
1505 #endif
1506  QML_END_INSTR(CleanupUrl)
1507 
1508  QML_BEGIN_INSTR(Fetch)
1509  {
1510  const Register &input = registers[instr->fetch.objectReg];
1511  Register &output = registers[instr->fetch.output];
1512 
1513  if (input.isUndefined()) {
1514  throwException(instr->fetch.exceptionId, error, program, context);
1515  return;
1516  }
1517 
1518  QObject *object = input.getQObject();
1519  if (!object) {
1520  output.setUndefined();
1521  } else {
1522  void *argv[] = { output.typeDataPtr(), 0 };
1523  QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv);
1524  }
1525  }
1526  QML_END_INSTR(Fetch)
1527 
1528  QML_BEGIN_INSTR(Store)
1529  {
1530  Register &data = registers[instr->store.reg];
1531  if (data.isUndefined()) {
1532  throwException(instr->store.exceptionId, error, program, context,
1533  QLatin1String("Unable to assign undefined value"));
1534  return;
1535  }
1536 
1537  int status = -1;
1538  void *argv[] = { data.typeDataPtr(), 0, &status, &storeFlags };
1540  instr->store.index, argv);
1541  }
1542  QML_END_INSTR(Store)
1543 
1544  QML_BEGIN_INSTR(Copy)
1545  registers[instr->copy.reg] = registers[instr->copy.src];
1546  QML_END_INSTR(Copy)
1547 
1548  QML_BEGIN_INSTR(Skip)
1549  if (instr->skip.reg == -1 || !registers[instr->skip.reg].getbool())
1550  instr += instr->skip.count;
1551  QML_END_INSTR(Skip)
1552 
1553  QML_BEGIN_INSTR(Done)
1554  return;
1555  QML_END_INSTR(Done)
1556 
1557  QML_BEGIN_INSTR(InitString)
1558  if (!identifiers[instr->initstring.offset].identifier) {
1559  quint32 len = *(quint32 *)(data + instr->initstring.dataIdx);
1560  QChar *strdata = (QChar *)(data + instr->initstring.dataIdx + sizeof(quint32));
1561 
1562  QString str = QString::fromRawData(strdata, len);
1563 
1564  identifiers[instr->initstring.offset] = engine->objectClass->createPersistentIdentifier(str);
1565  }
1566  QML_END_INSTR(InitString)
1567 
1568  QML_BEGIN_INSTR(FindGenericTerminal)
1569  // We start the search in the parent context, as we know that the
1570  // name is not present in the current context or it would have been
1571  // found during the static compile
1572  findgeneric(registers + instr->find.reg, instr->find.subscribeIndex,
1573  context->parent,
1574  identifiers[instr->find.name].identifier,
1575  instr->common.type == Instr::FindGenericTerminal);
1576  QML_END_INSTR(FindGenericTerminal)
1577 
1578  QML_BEGIN_INSTR(FindGeneric)
1579  // We start the search in the parent context, as we know that the
1580  // name is not present in the current context or it would have been
1581  // found during the static compile
1582  findgeneric(registers + instr->find.reg, instr->find.subscribeIndex,
1583  context->parent,
1584  identifiers[instr->find.name].identifier,
1585  instr->common.type == Instr::FindGenericTerminal);
1586  QML_END_INSTR(FindGeneric)
1587 
1588  QML_BEGIN_INSTR(FindPropertyTerminal)
1589  {
1590  const Register &object = registers[instr->find.src];
1591  if (object.isUndefined()) {
1592  throwException(instr->find.exceptionId, error, program, context);
1593  return;
1594  }
1595 
1596  findproperty(object.getQObject(), registers + instr->find.reg,
1598  instr->find.subscribeIndex, identifiers[instr->find.name].identifier,
1599  instr->common.type == Instr::FindPropertyTerminal);
1600  }
1601  QML_END_INSTR(FindPropertyTerminal)
1602 
1603  QML_BEGIN_INSTR(FindProperty)
1604  {
1605  const Register &object = registers[instr->find.src];
1606  if (object.isUndefined()) {
1607  throwException(instr->find.exceptionId, error, program, context);
1608  return;
1609  }
1610 
1611  findproperty(object.getQObject(), registers + instr->find.reg,
1613  instr->find.subscribeIndex, identifiers[instr->find.name].identifier,
1614  instr->common.type == Instr::FindPropertyTerminal);
1615  }
1616  QML_END_INSTR(FindProperty)
1617 
1618  QML_BEGIN_INSTR(CleanupGeneric)
1619  {
1620  int type = registers[instr->cleanup.reg].gettype();
1621  if (type == qMetaTypeId<QVariant>()) {
1622  registers[instr->cleanup.reg].getvariantptr()->~QVariant();
1623 #ifdef REGISTER_CLEANUP_DEBUG
1624  registers[instr->cleanup.reg].setUndefined();
1625 #endif
1626  } else if (type == QMetaType::QString) {
1627  registers[instr->cleanup.reg].getstringptr()->~QString();
1628 #ifdef REGISTER_CLEANUP_DEBUG
1629  registers[instr->cleanup.reg].setUndefined();
1630 #endif
1631  } else if (type == QMetaType::QUrl) {
1632  registers[instr->cleanup.reg].geturlptr()->~QUrl();
1633 #ifdef REGISTER_CLEANUP_DEBUG
1634  registers[instr->cleanup.reg].setUndefined();
1635 #endif
1636  }
1637  }
1638  QML_END_INSTR(CleanupGeneric)
1639 
1640  QML_BEGIN_INSTR(ConvertGenericToReal)
1641  {
1642  Register &output = registers[instr->unaryop.output];
1643  Register &input = registers[instr->unaryop.src];
1644  bool ok = true;
1645  output.setqreal(toReal(&input, input.gettype(), &ok));
1646  if (!ok) output.setUndefined();
1647  }
1648  QML_END_INSTR(ConvertGenericToReal)
1649 
1650  QML_BEGIN_INSTR(ConvertGenericToBool)
1651  {
1652  Register &output = registers[instr->unaryop.output];
1653  Register &input = registers[instr->unaryop.src];
1654  bool ok = true;
1655  output.setbool(toBool(&input, input.gettype(), &ok));
1656  if (!ok) output.setUndefined();
1657  }
1658  QML_END_INSTR(ConvertGenericToBool)
1659 
1660  QML_BEGIN_INSTR(ConvertGenericToString)
1661  {
1662  Register &output = registers[instr->unaryop.output];
1663  Register &input = registers[instr->unaryop.src];
1664  bool ok = true;
1665  QString str = toString(&input, input.gettype(), &ok);
1666  if (ok) { new (output.getstringptr()) QString(str); output.settype(QMetaType::QString); }
1667  else { output.setUndefined(); }
1668  }
1669  QML_END_INSTR(ConvertGenericToString)
1670 
1671  QML_BEGIN_INSTR(ConvertGenericToUrl)
1672  {
1673  Register &output = registers[instr->unaryop.output];
1674  Register &input = registers[instr->unaryop.src];
1675  bool ok = true;
1676  QUrl url = toUrl(&input, input.gettype(), context, &ok);
1677  if (ok) { new (output.geturlptr()) QUrl(url); output.settype(QMetaType::QUrl); }
1678  else { output.setUndefined(); }
1679  }
1680  QML_END_INSTR(ConvertGenericToUrl)
1681 
1682 #ifdef QML_THREADED_INTERPRETER
1683  // nothing to do
1684 #else
1685  default:
1686  qFatal("EEK");
1687  break;
1688  } // switch
1689 
1690  ++instr;
1691  } // while
1692 #endif
1693 }
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
QDeclarativeEngine * engine
QScriptDeclarativeClass::PersistentIdentifier * identifiers
static int metacall(QObject *, Call, int, void **)
void subscribe(QObject *o, int notifyIndex, int subIndex)
void subscribeId(QDeclarativeContextData *p, int idIndex, int subIndex)
static void throwException(int id, QDeclarativeDelayedError *error, Program *program, QDeclarativeContextData *context, const QString &description=QString())
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define QML_INSTR_ADDR(I)
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
QDeclarativeContextData * parent
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
PersistentIdentifier createPersistentIdentifier(const QString &)
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static QString fromRawData(const QChar *, int size)
Constructs a QString that uses the first size Unicode characters in the array unicode.
Definition: qstring.cpp:7673
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
Q_DECLARATIVE_EXPORT QObject * qmlAttachedPropertiesObjectById(int, const QObject *, bool create=true)
static bool toBool(Register *reg, int type, bool *ok=0)
static QString toString(Register *reg, int type, bool *ok=0)
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QDeclarativePropertyCache::Data * findproperty(QObject *obj, const QScriptDeclarativeClass::Identifier &name, QDeclarativeEnginePrivate *enginePriv, QDeclarativePropertyCache::Data &local)
QDeclarativeObjectScriptClass * objectClass
Q_CORE_EXPORT void qFatal(const char *,...)
static void dumpInstruction(const Instr *instr)
unsigned int quint32
Definition: qglobal.h:938
#define QML_BEGIN_INSTR(I)
#define QML_END_INSTR(I)
static QUrl toUrl(Register *reg, int type, QDeclarativeContextData *context, bool *ok=0)
#define FOR_EACH_QML_INSTR(F)
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
static qreal toReal(Register *reg, int type, bool *ok=0)
void findgeneric(Register *output, int subIdx, QDeclarativeContextData *context, const QScriptDeclarativeClass::Identifier &name, bool isTerminal)

◆ subscribe()

void QDeclarativeCompiledBindingsPrivate::subscribe ( QObject o,
int  notifyIndex,
int  subIndex 
)
inline

◆ subscribeId()

void QDeclarativeCompiledBindingsPrivate::subscribeId ( QDeclarativeContextData p,
int  idIndex,
int  subIndex 
)
inline

Properties

◆ dataRef

QDeclarativeRefCount* QDeclarativeCompiledBindingsPrivate::dataRef

◆ identifiers

QScriptDeclarativeClass::PersistentIdentifier* QDeclarativeCompiledBindingsPrivate::identifiers

◆ m_bindings

Binding* QDeclarativeCompiledBindingsPrivate::m_bindings

Definition at line 240 of file qdeclarativecompiledbindings.cpp.

◆ m_bindingsDisconnected

bool QDeclarativeCompiledBindingsPrivate::m_bindingsDisconnected

Definition at line 242 of file qdeclarativecompiledbindings.cpp.

◆ m_signalTable

quint32* QDeclarativeCompiledBindingsPrivate::m_signalTable

Definition at line 241 of file qdeclarativecompiledbindings.cpp.

◆ methodCount

int QDeclarativeCompiledBindingsPrivate::methodCount = -1
static

◆ programData

const char* QDeclarativeCompiledBindingsPrivate::programData

Definition at line 238 of file qdeclarativecompiledbindings.cpp.

◆ subscriptions

Subscription* QDeclarativeCompiledBindingsPrivate::subscriptions

The documentation for this class was generated from the following file: