Qt 4.8
qmetaobject.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qmetaobject.h"
43 #include "qmetatype.h"
44 #include "qobject.h"
45 
46 #include <qcoreapplication.h>
47 #include <qcoreevent.h>
48 #include <qdatastream.h>
49 #include <qstringlist.h>
50 #include <qthread.h>
51 #include <qvarlengtharray.h>
52 #include <qvariant.h>
53 #include <qhash.h>
54 #include <qdebug.h>
55 #include <qsemaphore.h>
56 
57 #include "private/qobject_p.h"
58 #include "private/qmetaobject_p.h"
59 
60 #include <ctype.h>
61 
63 
149 static inline const QMetaObjectPrivate *priv(const uint* data)
150 { return reinterpret_cast<const QMetaObjectPrivate*>(data); }
151 
152 
170  QGenericArgument val1,
171  QGenericArgument val2,
172  QGenericArgument val3,
173  QGenericArgument val4,
174  QGenericArgument val5,
175  QGenericArgument val6,
176  QGenericArgument val7,
177  QGenericArgument val8,
178  QGenericArgument val9) const
179 {
180  QByteArray constructorName = className();
181  {
182  int idx = constructorName.lastIndexOf(':');
183  if (idx != -1)
184  constructorName.remove(0, idx+1); // remove qualified part
185  }
187  sig.append(constructorName.constData(), constructorName.length());
188  sig.append('(');
189 
190  enum { MaximumParamCount = 10 };
191  const char *typeNames[] = {val0.name(), val1.name(), val2.name(), val3.name(), val4.name(),
192  val5.name(), val6.name(), val7.name(), val8.name(), val9.name()};
193 
194  int paramCount;
195  for (paramCount = 0; paramCount < MaximumParamCount; ++paramCount) {
196  int len = qstrlen(typeNames[paramCount]);
197  if (len <= 0)
198  break;
199  sig.append(typeNames[paramCount], len);
200  sig.append(',');
201  }
202  if (paramCount == 0)
203  sig.append(')'); // no parameters
204  else
205  sig[sig.size() - 1] = ')';
206  sig.append('\0');
207 
208  int idx = indexOfConstructor(sig.constData());
209  if (idx < 0) {
211  idx = indexOfConstructor(norm.constData());
212  }
213  if (idx < 0)
214  return 0;
215 
216  QVariant ret(QMetaType::QObjectStar, (void*)0);
217  void *param[] = {ret.data(), val0.data(), val1.data(), val2.data(), val3.data(), val4.data(),
218  val5.data(), val6.data(), val7.data(), val8.data(), val9.data()};
219 
220  if (static_metacall(CreateInstance, idx, param) >= 0)
221  return 0;
222  return *reinterpret_cast<QObject**>(param[0]);
223 }
224 
228 int QMetaObject::static_metacall(Call cl, int idx, void **argv) const
229 {
230  const QMetaObjectExtraData *extra = reinterpret_cast<const QMetaObjectExtraData *>(d.extradata);
231  if (priv(d.data)->revision >= 6) {
232  if (!extra || !extra->static_metacall)
233  return 0;
234  extra->static_metacall(0, cl, idx, argv);
235  return -1;
236  } else if (priv(d.data)->revision >= 2) {
237  if (!extra || !extra->static_metacall)
238  return 0;
239  typedef int (*OldMetacall)(QMetaObject::Call, int, void **);
240  OldMetacall o = reinterpret_cast<OldMetacall>(extra->static_metacall);
241  return o(cl, idx, argv);
242  }
243  return 0;
244 }
245 
249 int QMetaObject::metacall(QObject *object, Call cl, int idx, void **argv)
250 {
251  if (QMetaObject *mo = object->d_ptr->metaObject)
252  return static_cast<QAbstractDynamicMetaObject*>(mo)->metaCall(cl, idx, argv);
253  else
254  return object->qt_metacall(cl, idx, argv);
255 }
256 
284 {
285  if (obj) {
286  const QMetaObject *m = obj->metaObject();
287  do {
288  if (m == this)
289  return obj;
290  } while ((m = m->d.superdata));
291  }
292  return 0;
293 }
294 
304 const QObject *QMetaObject::cast(const QObject *obj) const
305 {
306  if (obj) {
307  const QMetaObject *m = obj->metaObject();
308  do {
309  if (m == this)
310  return obj;
311  } while ((m = m->d.superdata));
312  }
313  return 0;
314 }
315 
316 #ifndef QT_NO_TRANSLATION
317 
320 QString QMetaObject::tr(const char *s, const char *c) const
321 {
323 }
324 
328 QString QMetaObject::tr(const char *s, const char *c, int n) const
329 {
330  return QCoreApplication::translate(d.stringdata, s, c, QCoreApplication::CodecForTr, n);
331 }
332 
336 QString QMetaObject::trUtf8(const char *s, const char *c) const
337 {
339 }
340 
344 QString QMetaObject::trUtf8(const char *s, const char *c, int n) const
345 {
346  return QCoreApplication::translate(d.stringdata, s, c, QCoreApplication::UnicodeUTF8, n);
347 }
348 #endif // QT_NO_TRANSLATION
349 
361 {
362  int offset = 0;
363  const QMetaObject *m = d.superdata;
364  while (m) {
365  offset += priv(m->d.data)->methodCount;
366  m = m->d.superdata;
367  }
368  return offset;
369 }
370 
371 
383 {
384  int offset = 0;
385  const QMetaObject *m = d.superdata;
386  while (m) {
387  offset += priv(m->d.data)->enumeratorCount;
388  m = m->d.superdata;
389  }
390  return offset;
391 }
392 
404 {
405  int offset = 0;
406  const QMetaObject *m = d.superdata;
407  while (m) {
408  offset += priv(m->d.data)->propertyCount;
409  m = m->d.superdata;
410  }
411  return offset;
412 }
413 
425 {
426  int offset = 0;
427  const QMetaObject *m = d.superdata;
428  while (m) {
429  offset += priv(m->d.data)->classInfoCount;
430  m = m->d.superdata;
431  }
432  return offset;
433 }
434 
446 {
447  if (priv(d.data)->revision < 2)
448  return 0;
449  return priv(d.data)->constructorCount;
450 }
451 
466 {
467  int n = priv(d.data)->methodCount;
468  const QMetaObject *m = d.superdata;
469  while (m) {
470  n += priv(m->d.data)->methodCount;
471  m = m->d.superdata;
472  }
473  return n;
474 }
475 
482 {
483  int n = priv(d.data)->enumeratorCount;
484  const QMetaObject *m = d.superdata;
485  while (m) {
486  n += priv(m->d.data)->enumeratorCount;
487  m = m->d.superdata;
488  }
489  return n;
490 }
491 
504 {
505  int n = priv(d.data)->propertyCount;
506  const QMetaObject *m = d.superdata;
507  while (m) {
508  n += priv(m->d.data)->propertyCount;
509  m = m->d.superdata;
510  }
511  return n;
512 }
513 
520 {
521  int n = priv(d.data)->classInfoCount;
522  const QMetaObject *m = d.superdata;
523  while (m) {
524  n += priv(m->d.data)->classInfoCount;
525  m = m->d.superdata;
526  }
527  return n;
528 }
529 
536 template<int MethodType>
537 static inline int indexOfMethodRelative(const QMetaObject **baseObject,
538  const char *method,
539  bool normalizeStringData)
540 {
541  for (const QMetaObject *m = *baseObject; m; m = m->d.superdata) {
542  int i = (MethodType == MethodSignal && priv(m->d.data)->revision >= 4)
543  ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1);
544  const int end = (MethodType == MethodSlot && priv(m->d.data)->revision >= 4)
545  ? (priv(m->d.data)->signalCount) : 0;
546  if (!normalizeStringData) {
547  for (; i >= end; --i) {
548  const char *stringdata = m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5*i];
549  if (method[0] == stringdata[0] && strcmp(method + 1, stringdata + 1) == 0) {
550  *baseObject = m;
551  return i;
552  }
553  }
554  } else if (priv(m->d.data)->revision < 5) {
555  for (; i >= end; --i) {
556  const char *stringdata = (m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5 * i]);
558  if (normalizedSignature == method) {
559  *baseObject = m;
560  return i;
561  }
562  }
563  }
564  }
565  return -1;
566 }
567 
568 
583 {
584  if (priv(d.data)->revision < 2)
585  return -1;
586  for (int i = priv(d.data)->constructorCount-1; i >= 0; --i) {
587  const char *data = d.stringdata + d.data[priv(d.data)->constructorData + 5*i];
588  if (data[0] == constructor[0] && strcmp(constructor + 1, data + 1) == 0) {
589  return i;
590  }
591  }
592  return -1;
593 }
594 
603 int QMetaObject::indexOfMethod(const char *method) const
604 {
605  const QMetaObject *m = this;
606  int i = indexOfMethodRelative<0>(&m, method, false);
607  if (i < 0) {
608  m = this;
609  i = indexOfMethodRelative<0>(&m, method, true);
610  }
611  if (i >= 0)
612  i += m->methodOffset();
613  return i;
614 }
615 
627 int QMetaObject::indexOfSignal(const char *signal) const
628 {
629  const QMetaObject *m = this;
630  int i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal, false);
631  if (i < 0) {
632  m = this;
633  i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal, true);
634  }
635  if (i >= 0)
636  i += m->methodOffset();
637  return i;
638 }
639 
649  const char *signal,
650  bool normalizeStringData)
651 {
652  int i = indexOfMethodRelative<MethodSignal>(baseObject, signal, normalizeStringData);
653 #ifndef QT_NO_DEBUG
654  const QMetaObject *m = *baseObject;
655  if (i >= 0 && m && m->d.superdata) {
656  int conflict = m->d.superdata->indexOfMethod(signal);
657  if (conflict >= 0)
658  qWarning("QMetaObject::indexOfSignal: signal %s from %s redefined in %s",
659  signal, m->d.superdata->d.stringdata, m->d.stringdata);
660  }
661 #endif
662  return i;
663 }
664 
673 int QMetaObject::indexOfSlot(const char *slot) const
674 {
675  const QMetaObject *m = this;
676  int i = QMetaObjectPrivate::indexOfSlotRelative(&m, slot, false);
677  if (i < 0)
678  i = QMetaObjectPrivate::indexOfSlotRelative(&m, slot, true);
679  if (i >= 0)
680  i += m->methodOffset();
681  return i;
682 }
683 
684 // same as indexOfSignalRelative but for slots.
686  const char *slot,
687  bool normalizeStringData)
688 {
689  return indexOfMethodRelative<MethodSlot>(m, slot, normalizeStringData);
690 }
691 
692 static const QMetaObject *QMetaObject_findMetaObject(const QMetaObject *self, const char *name)
693 {
694  while (self) {
695  if (strcmp(self->d.stringdata, name) == 0)
696  return self;
697  if (self->d.extradata) {
698 #ifdef Q_NO_DATA_RELOCATION
699  const QMetaObjectAccessor *e;
700  Q_ASSERT(priv(self->d.data)->revision >= 2);
701 #else
702  const QMetaObject **e;
703  if (priv(self->d.data)->revision < 2) {
704  e = (const QMetaObject**)(self->d.extradata);
705  } else
706 #endif
707  {
708  const QMetaObjectExtraData *extra = (const QMetaObjectExtraData*)(self->d.extradata);
709  e = extra->objects;
710  }
711  if (e) {
712  while (*e) {
713 #ifdef Q_NO_DATA_RELOCATION
714  if (const QMetaObject *m =QMetaObject_findMetaObject(&((*e)()), name))
715 #else
716  if (const QMetaObject *m =QMetaObject_findMetaObject((*e), name))
717 #endif
718  return m;
719  ++e;
720  }
721  }
722  }
723  self = self->d.superdata;
724  }
725  return self;
726 }
727 
734 int QMetaObject::indexOfEnumerator(const char *name) const
735 {
736  const QMetaObject *m = this;
737  while (m) {
738  const QMetaObjectPrivate *d = priv(m->d.data);
739  for (int i = d->enumeratorCount - 1; i >= 0; --i) {
740  const char *prop = m->d.stringdata + m->d.data[d->enumeratorData + 4*i];
741  if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
742  i += m->enumeratorOffset();
743  return i;
744  }
745  }
746  m = m->d.superdata;
747  }
748  return -1;
749 }
750 
757 int QMetaObject::indexOfProperty(const char *name) const
758 {
759  const QMetaObject *m = this;
760  while (m) {
761  const QMetaObjectPrivate *d = priv(m->d.data);
762  for (int i = d->propertyCount-1; i >= 0; --i) {
763  const char *prop = m->d.stringdata + m->d.data[d->propertyData + 3*i];
764  if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) {
765  i += m->propertyOffset();
766  return i;
767  }
768  }
769  m = m->d.superdata;
770  }
771 
772  if (priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)) {
774  const_cast<QAbstractDynamicMetaObject *>(static_cast<const QAbstractDynamicMetaObject *>(this));
775 
776  return me->createProperty(name, 0);
777  }
778 
779  return -1;
780 }
781 
788 int QMetaObject::indexOfClassInfo(const char *name) const
789 {
790  int i = -1;
791  const QMetaObject *m = this;
792  while (m && i < 0) {
793  for (i = priv(m->d.data)->classInfoCount-1; i >= 0; --i)
794  if (strcmp(name, m->d.stringdata
795  + m->d.data[priv(m->d.data)->classInfoData + 2*i]) == 0) {
796  i += m->classInfoOffset();
797  break;
798  }
799  m = m->d.superdata;
800  }
801  return i;
802 }
803 
815 {
816  int i = index;
817  QMetaMethod result;
818  if (priv(d.data)->revision >= 2 && i >= 0 && i < priv(d.data)->constructorCount) {
819  result.mobj = this;
820  result.handle = priv(d.data)->constructorData + 5*i;
821  }
822  return result;
823 }
824 
831 {
832  int i = index;
833  i -= methodOffset();
834  if (i < 0 && d.superdata)
835  return d.superdata->method(index);
836 
837  QMetaMethod result;
838  if (i >= 0 && i < priv(d.data)->methodCount) {
839  result.mobj = this;
840  result.handle = priv(d.data)->methodData + 5*i;
841  }
842  return result;
843 }
844 
851 {
852  int i = index;
853  i -= enumeratorOffset();
854  if (i < 0 && d.superdata)
855  return d.superdata->enumerator(index);
856 
857  QMetaEnum result;
858  if (i >= 0 && i < priv(d.data)->enumeratorCount) {
859  result.mobj = this;
860  result.handle = priv(d.data)->enumeratorData + 4*i;
861  }
862  return result;
863 }
864 
872 {
873  int i = index;
874  i -= propertyOffset();
875  if (i < 0 && d.superdata)
876  return d.superdata->property(index);
877 
878  QMetaProperty result;
879  if (i >= 0 && i < priv(d.data)->propertyCount) {
880  int handle = priv(d.data)->propertyData + 3*i;
881  int flags = d.data[handle + 2];
882  const char *type = d.stringdata + d.data[handle + 1];
883  result.mobj = this;
884  result.handle = handle;
885  result.idx = i;
886 
887  if (flags & EnumOrFlag) {
888  result.menum = enumerator(indexOfEnumerator(type));
889  if (!result.menum.isValid()) {
890  QByteArray enum_name = type;
891  QByteArray scope_name = d.stringdata;
892  int s = enum_name.lastIndexOf("::");
893  if (s > 0) {
894  scope_name = enum_name.left(s);
895  enum_name = enum_name.mid(s + 2);
896  }
897  const QMetaObject *scope = 0;
898  if (scope_name == "Qt")
900  else
901  scope = QMetaObject_findMetaObject(this, scope_name);
902  if (scope)
903  result.menum = scope->enumerator(scope->indexOfEnumerator(enum_name));
904  }
905  }
906  }
907  return result;
908 }
909 
921 {
922  const int propCount = propertyCount();
923  for (int i = propCount - 1; i >= 0; --i) {
924  const QMetaProperty prop = property(i);
925  if (prop.isUser())
926  return prop;
927  }
928  return QMetaProperty();
929 }
930 
942 {
943  int i = index;
944  i -= classInfoOffset();
945  if (i < 0 && d.superdata)
946  return d.superdata->classInfo(index);
947 
948  QMetaClassInfo result;
949  if (i >= 0 && i < priv(d.data)->classInfoCount) {
950  result.mobj = this;
951  result.handle = priv(d.data)->classInfoData + 2*i;
952  }
953  return result;
954 }
955 
964 bool QMetaObject::checkConnectArgs(const char *signal, const char *method)
965 {
966  const char *s1 = signal;
967  const char *s2 = method;
968  while (*s1++ != '(') { } // scan to first '('
969  while (*s2++ != '(') { }
970  if (*s2 == ')' || qstrcmp(s1,s2) == 0) // method has no args or
971  return true; // exact match
972  int s1len = qstrlen(s1);
973  int s2len = qstrlen(s2);
974  if (s2len < s1len && strncmp(s1,s2,s2len-1)==0 && s1[s2len-1]==',')
975  return true; // method has less args
976  return false;
977 }
978 
979 static void qRemoveWhitespace(const char *s, char *d)
980 {
981  char last = 0;
982  while (*s && is_space(*s))
983  s++;
984  while (*s) {
985  while (*s && !is_space(*s))
986  last = *d++ = *s++;
987  while (*s && is_space(*s))
988  s++;
989  if (*s && ((is_ident_char(*s) && is_ident_char(last))
990  || ((*s == ':') && (last == '<')))) {
991  last = *d++ = ' ';
992  }
993  }
994  *d = '\0';
995 }
996 
997 static char *qNormalizeType(char *d, int &templdepth, QByteArray &result)
998 {
999  const char *t = d;
1000  while (*d && (templdepth
1001  || (*d != ',' && *d != ')'))) {
1002  if (*d == '<')
1003  ++templdepth;
1004  if (*d == '>')
1005  --templdepth;
1006  ++d;
1007  }
1008  if (strncmp("void", t, d - t) != 0)
1009  result += normalizeTypeInternal(t, d);
1010 
1011  return d;
1012 }
1013 
1014 
1033 {
1034  QByteArray result;
1035 
1036  if (!type || !*type)
1037  return result;
1038 
1039  QVarLengthArray<char> stackbuf(qstrlen(type) + 1);
1040  qRemoveWhitespace(type, stackbuf.data());
1041  int templdepth = 0;
1042  qNormalizeType(stackbuf.data(), templdepth, result);
1043 
1044  return result;
1045 }
1046 
1059 {
1060  QByteArray result;
1061  if (!method || !*method)
1062  return result;
1063  int len = int(strlen(method));
1064  QVarLengthArray<char> stackbuf(len + 1);
1065  char *d = stackbuf.data();
1066  qRemoveWhitespace(method, d);
1067 
1068  result.reserve(len);
1069 
1070  int argdepth = 0;
1071  int templdepth = 0;
1072  while (*d) {
1073  if (argdepth == 1) {
1074  d = qNormalizeType(d, templdepth, result);
1075  if (!*d) //most likely an invalid signature.
1076  break;
1077  }
1078  if (*d == '(')
1079  ++argdepth;
1080  if (*d == ')')
1081  --argdepth;
1082  result += *d++;
1083  }
1084 
1085  return result;
1086 }
1087 
1088 enum { MaximumParamCount = 11 }; // up to 10 arguments + 1 return value
1089 
1157  const char *member,
1160  QGenericArgument val0,
1161  QGenericArgument val1,
1162  QGenericArgument val2,
1163  QGenericArgument val3,
1164  QGenericArgument val4,
1165  QGenericArgument val5,
1166  QGenericArgument val6,
1167  QGenericArgument val7,
1168  QGenericArgument val8,
1169  QGenericArgument val9)
1170 {
1171  if (!obj)
1172  return false;
1173 
1175  int len = qstrlen(member);
1176  if (len <= 0)
1177  return false;
1178  sig.append(member, len);
1179  sig.append('(');
1180 
1181  const char *typeNames[] = {ret.name(), val0.name(), val1.name(), val2.name(), val3.name(),
1182  val4.name(), val5.name(), val6.name(), val7.name(), val8.name(),
1183  val9.name()};
1184 
1185  int paramCount;
1186  for (paramCount = 1; paramCount < MaximumParamCount; ++paramCount) {
1187  len = qstrlen(typeNames[paramCount]);
1188  if (len <= 0)
1189  break;
1190  sig.append(typeNames[paramCount], len);
1191  sig.append(',');
1192  }
1193  if (paramCount == 1)
1194  sig.append(')'); // no parameters
1195  else
1196  sig[sig.size() - 1] = ')';
1197  sig.append('\0');
1198 
1199  int idx = obj->metaObject()->indexOfMethod(sig.constData());
1200  if (idx < 0) {
1202  idx = obj->metaObject()->indexOfMethod(norm.constData());
1203  }
1204 
1205  if (idx < 0 || idx >= obj->metaObject()->methodCount()) {
1206  qWarning("QMetaObject::invokeMethod: No such method %s::%s",
1207  obj->metaObject()->className(), sig.constData());
1208  return false;
1209  }
1210  QMetaMethod method = obj->metaObject()->method(idx);
1211  return method.invoke(obj, type, ret,
1212  val0, val1, val2, val3, val4, val5, val6, val7, val8, val9);
1213 }
1214 
1327 const char *QMetaMethod::signature() const
1328 {
1329  if (!mobj)
1330  return 0;
1331  return mobj->d.stringdata + mobj->d.data[handle];
1332 }
1333 
1340 {
1341  QList<QByteArray> list;
1342  if (!mobj)
1343  return list;
1344  const char *signature = mobj->d.stringdata + mobj->d.data[handle];
1345  while (*signature && *signature != '(')
1346  ++signature;
1347  while (*signature && *signature != ')' && *++signature != ')') {
1348  const char *begin = signature;
1349  int level = 0;
1350  while (*signature && (level > 0 || *signature != ',') && *signature != ')') {
1351  if (*signature == '<')
1352  ++level;
1353  else if (*signature == '>')
1354  --level;
1355  ++signature;
1356  }
1357  list += QByteArray(begin, signature - begin);
1358  }
1359  return list;
1360 }
1361 
1368 {
1369  QList<QByteArray> list;
1370  if (!mobj)
1371  return list;
1372  const char *names = mobj->d.stringdata + mobj->d.data[handle + 1];
1373  if (*names == 0) {
1374  // do we have one or zero arguments?
1375  const char *signature = mobj->d.stringdata + mobj->d.data[handle];
1376  while (*signature && *signature != '(')
1377  ++signature;
1378  if (*++signature != ')')
1379  list += QByteArray();
1380  } else {
1381  --names;
1382  do {
1383  const char *begin = ++names;
1384  while (*names && *names != ',')
1385  ++names;
1386  list += QByteArray(begin, names - begin);
1387  } while (*names);
1388  }
1389  return list;
1390 }
1391 
1392 
1397 const char *QMetaMethod::typeName() const
1398 {
1399  if (!mobj)
1400  return 0;
1401  return mobj->d.stringdata + mobj->d.data[handle + 2];
1402 }
1403 
1434 const char *QMetaMethod::tag() const
1435 {
1436  if (!mobj)
1437  return 0;
1438  return mobj->d.stringdata + mobj->d.data[handle + 3];
1439 }
1440 
1441 
1444 {
1445  if (!mobj)
1446  return false;
1447  return ((mobj->d.data[handle + 4])>>4);
1448 }
1449 
1459 {
1460  if (!mobj)
1461  return -1;
1462  return ((handle - priv(mobj->d.data)->methodData) / 5) + mobj->methodOffset();
1463 }
1464 
1475 {
1476  if (!mobj)
1477  return 0;
1478  if ((QMetaMethod::Access)(mobj->d.data[handle + 4] & MethodRevisioned)) {
1479  int offset = priv(mobj->d.data)->methodData
1480  + priv(mobj->d.data)->methodCount * 5
1481  + (handle - priv(mobj->d.data)->methodData) / 5;
1482  return mobj->d.data[offset];
1483  }
1484  return 0;
1485 }
1486 
1497 {
1498  if (!mobj)
1499  return Private;
1500  return (QMetaMethod::Access)(mobj->d.data[handle + 4] & AccessMask);
1501 }
1502 
1509 {
1510  if (!mobj)
1511  return QMetaMethod::Method;
1512  return (QMetaMethod::MethodType)((mobj->d.data[handle + 4] & MethodTypeMask)>>2);
1513 }
1514 
1584  Qt::ConnectionType connectionType,
1585  QGenericReturnArgument returnValue,
1586  QGenericArgument val0,
1587  QGenericArgument val1,
1588  QGenericArgument val2,
1589  QGenericArgument val3,
1590  QGenericArgument val4,
1591  QGenericArgument val5,
1592  QGenericArgument val6,
1593  QGenericArgument val7,
1594  QGenericArgument val8,
1595  QGenericArgument val9) const
1596 {
1597  if (!object || !mobj)
1598  return false;
1599 
1600  Q_ASSERT(mobj->cast(object));
1601 
1602  // check return type
1603  if (returnValue.data()) {
1604  const char *retType = typeName();
1605  if (qstrcmp(returnValue.name(), retType) != 0) {
1606  // normalize the return value as well
1607  // the trick here is to make a function signature out of the return type
1608  // so that we can call normalizedSignature() and avoid duplicating code
1609  QByteArray unnormalized;
1610  int len = qstrlen(returnValue.name());
1611 
1612  unnormalized.reserve(len + 3);
1613  unnormalized = "_("; // the function is called "_"
1614  unnormalized.append(returnValue.name());
1615  unnormalized.append(')');
1616 
1617  QByteArray normalized = QMetaObject::normalizedSignature(unnormalized.constData());
1618  normalized.truncate(normalized.length() - 1); // drop the ending ')'
1619 
1620  if (qstrcmp(normalized.constData() + 2, retType) != 0)
1621  return false;
1622  }
1623  }
1624 
1625  // check argument count (we don't allow invoking a method if given too few arguments)
1626  const char *typeNames[] = {
1627  returnValue.name(),
1628  val0.name(),
1629  val1.name(),
1630  val2.name(),
1631  val3.name(),
1632  val4.name(),
1633  val5.name(),
1634  val6.name(),
1635  val7.name(),
1636  val8.name(),
1637  val9.name()
1638  };
1639  int paramCount;
1640  for (paramCount = 1; paramCount < MaximumParamCount; ++paramCount) {
1641  if (qstrlen(typeNames[paramCount]) <= 0)
1642  break;
1643  }
1644  int metaMethodArgumentCount = 0;
1645  {
1646  // based on QMetaObject::parameterNames()
1647  const char *names = mobj->d.stringdata + mobj->d.data[handle + 1];
1648  if (*names == 0) {
1649  // do we have one or zero arguments?
1650  const char *signature = mobj->d.stringdata + mobj->d.data[handle];
1651  while (*signature && *signature != '(')
1652  ++signature;
1653  if (*++signature != ')')
1654  ++metaMethodArgumentCount;
1655  } else {
1656  --names;
1657  do {
1658  ++names;
1659  while (*names && *names != ',')
1660  ++names;
1661  ++metaMethodArgumentCount;
1662  } while (*names);
1663  }
1664  }
1665  if (paramCount <= metaMethodArgumentCount)
1666  return false;
1667 
1668  // check connection type
1669  QThread *currentThread = QThread::currentThread();
1670  QThread *objectThread = object->thread();
1671  if (connectionType == Qt::AutoConnection) {
1672  connectionType = currentThread == objectThread
1675  }
1676 
1677 #ifdef QT_NO_THREAD
1678  if (connectionType == Qt::BlockingQueuedConnection) {
1679  connectionType = Qt::DirectConnection;
1680  }
1681 #endif
1682 
1683  // invoke!
1684  void *param[] = {
1685  returnValue.data(),
1686  val0.data(),
1687  val1.data(),
1688  val2.data(),
1689  val3.data(),
1690  val4.data(),
1691  val5.data(),
1692  val6.data(),
1693  val7.data(),
1694  val8.data(),
1695  val9.data()
1696  };
1697  // recompute the methodIndex by reversing the arithmetic in QMetaObject::property()
1698  int idx_relative = ((handle - priv(mobj->d.data)->methodData) / 5);
1699  int idx_offset = mobj->methodOffset();
1701  (QMetaObjectPrivate::get(mobj)->revision >= 6 && mobj->d.extradata)
1702  ? reinterpret_cast<const QMetaObjectExtraData *>(mobj->d.extradata)->static_metacall : 0;
1703 
1704  if (connectionType == Qt::DirectConnection) {
1705  if (callFunction) {
1706  callFunction(object, QMetaObject::InvokeMetaMethod, idx_relative, param);
1707  return true;
1708  } else {
1709  return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, idx_relative + idx_offset, param) < 0;
1710  }
1711  } else if (connectionType == Qt::QueuedConnection) {
1712  if (returnValue.data()) {
1713  qWarning("QMetaMethod::invoke: Unable to invoke methods with return values in "
1714  "queued connections");
1715  return false;
1716  }
1717 
1718  int nargs = 1; // include return type
1719  void **args = (void **) qMalloc(paramCount * sizeof(void *));
1720  Q_CHECK_PTR(args);
1721  int *types = (int *) qMalloc(paramCount * sizeof(int));
1722  Q_CHECK_PTR(types);
1723  types[0] = 0; // return type
1724  args[0] = 0;
1725 
1726  for (int i = 1; i < paramCount; ++i) {
1727  types[i] = QMetaType::type(typeNames[i]);
1728  if (types[i]) {
1729  args[i] = QMetaType::construct(types[i], param[i]);
1730  ++nargs;
1731  } else if (param[i]) {
1732  qWarning("QMetaMethod::invoke: Unable to handle unregistered datatype '%s'",
1733  typeNames[i]);
1734  for (int x = 1; x < i; ++x) {
1735  if (types[x] && args[x])
1736  QMetaType::destroy(types[x], args[x]);
1737  }
1738  qFree(types);
1739  qFree(args);
1740  return false;
1741  }
1742  }
1743 
1744  QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction,
1745  0, -1, nargs, types, args));
1746  } else { // blocking queued connection
1747 #ifndef QT_NO_THREAD
1748  if (currentThread == objectThread) {
1749  qWarning("QMetaMethod::invoke: Dead lock detected in "
1750  "BlockingQueuedConnection: Receiver is %s(%p)",
1751  mobj->className(), object);
1752  }
1753 
1754  QSemaphore semaphore;
1755  QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction,
1756  0, -1, 0, 0, param, &semaphore));
1757  semaphore.acquire();
1758 #endif // QT_NO_THREAD
1759  }
1760  return true;
1761 }
1762 
1872 const char *QMetaEnum::name() const
1873 {
1874  if (!mobj)
1875  return 0;
1876  return mobj->d.stringdata + mobj->d.data[handle];
1877 }
1878 
1885 {
1886  if (!mobj)
1887  return 0;
1888  return mobj->d.data[handle + 2];
1889 }
1890 
1891 
1897 const char *QMetaEnum::key(int index) const
1898 {
1899  if (!mobj)
1900  return 0;
1901  int count = mobj->d.data[handle + 2];
1902  int data = mobj->d.data[handle + 3];
1903  if (index >= 0 && index < count)
1904  return mobj->d.stringdata + mobj->d.data[data + 2*index];
1905  return 0;
1906 }
1907 
1914 int QMetaEnum::value(int index) const
1915 {
1916  if (!mobj)
1917  return 0;
1918  int count = mobj->d.data[handle + 2];
1919  int data = mobj->d.data[handle + 3];
1920  if (index >= 0 && index < count)
1921  return mobj->d.data[data + 2*index + 1];
1922  return -1;
1923 }
1924 
1925 
1935 bool QMetaEnum::isFlag() const
1936 {
1937  return mobj && mobj->d.data[handle + 1];
1938 }
1939 
1940 
1949 const char *QMetaEnum::scope() const
1950 {
1951  return mobj?mobj->d.stringdata : 0;
1952 }
1953 
1962 int QMetaEnum::keyToValue(const char *key) const
1963 {
1964  if (!mobj || !key)
1965  return -1;
1966  uint scope = 0;
1967  const char *qualified_key = key;
1968  const char *s = key + qstrlen(key);
1969  while (s > key && *s != ':')
1970  --s;
1971  if (s > key && *(s-1)==':') {
1972  scope = s - key - 1;
1973  key += scope + 2;
1974  }
1975  int count = mobj->d.data[handle + 2];
1976  int data = mobj->d.data[handle + 3];
1977  for (int i = 0; i < count; ++i)
1978  if ((!scope || (qstrlen(mobj->d.stringdata) == scope && strncmp(qualified_key, mobj->d.stringdata, scope) == 0))
1979  && strcmp(key, mobj->d.stringdata + mobj->d.data[data + 2*i]) == 0)
1980  return mobj->d.data[data + 2*i + 1];
1981  return -1;
1982 }
1983 
1992 const char* QMetaEnum::valueToKey(int value) const
1993 {
1994  if (!mobj)
1995  return 0;
1996  int count = mobj->d.data[handle + 2];
1997  int data = mobj->d.data[handle + 3];
1998  for (int i = 0; i < count; ++i)
1999  if (value == (int)mobj->d.data[data + 2*i + 1])
2000  return mobj->d.stringdata + mobj->d.data[data + 2*i];
2001  return 0;
2002 }
2003 
2011 int QMetaEnum::keysToValue(const char *keys) const
2012 {
2013  if (!mobj)
2014  return -1;
2016  //#### TODO write proper code, do not use QStringList
2017  int value = 0;
2018  int count = mobj->d.data[handle + 2];
2019  int data = mobj->d.data[handle + 3];
2020  for (int li = 0; li < l.size(); ++li) {
2021  QString trimmed = l.at(li).trimmed();
2022  QByteArray qualified_key = trimmed.toLatin1();
2023  const char *key = qualified_key.constData();
2024  uint scope = 0;
2025  const char *s = key + qstrlen(key);
2026  while (s > key && *s != ':')
2027  --s;
2028  if (s > key && *(s-1)==':') {
2029  scope = s - key - 1;
2030  key += scope + 2;
2031  }
2032  int i;
2033  for (i = count-1; i >= 0; --i)
2034  if ((!scope || (qstrlen(mobj->d.stringdata) == scope && strncmp(qualified_key.constData(), mobj->d.stringdata, scope) == 0))
2035  && strcmp(key, mobj->d.stringdata + mobj->d.data[data + 2*i]) == 0) {
2036  value |= mobj->d.data[data + 2*i + 1];
2037  break;
2038  }
2039  if (i < 0)
2040  value |= -1;
2041  }
2042  return value;
2043 }
2044 
2052 {
2053  QByteArray keys;
2054  if (!mobj)
2055  return keys;
2056  int count = mobj->d.data[handle + 2];
2057  int data = mobj->d.data[handle + 3];
2058  int v = value;
2059  for(int i = 0; i < count; i++) {
2060  int k = mobj->d.data[data + 2*i + 1];
2061  if ((k != 0 && (v & k) == k ) || (k == value)) {
2062  v = v & ~k;
2063  if (!keys.isEmpty())
2064  keys += '|';
2065  keys += mobj->d.stringdata + mobj->d.data[data + 2*i];
2066  }
2067  }
2068  return keys;
2069 }
2070 
2072 {
2073  return QByteArray(e.scope()) + "::" + e.name();
2074 }
2075 
2135  : mobj(0), handle(0), idx(0)
2136 {
2137 }
2138 
2139 
2145 const char *QMetaProperty::name() const
2146 {
2147  if (!mobj)
2148  return 0;
2149  int handle = priv(mobj->d.data)->propertyData + 3*idx;
2150  return mobj->d.stringdata + mobj->d.data[handle];
2151 }
2152 
2158 const char *QMetaProperty::typeName() const
2159 {
2160  if (!mobj)
2161  return 0;
2162  int handle = priv(mobj->d.data)->propertyData + 3*idx;
2163  return mobj->d.stringdata + mobj->d.data[handle + 1];
2164 }
2165 
2173 {
2174  if (!mobj)
2175  return QVariant::Invalid;
2176  int handle = priv(mobj->d.data)->propertyData + 3*idx;
2177  uint flags = mobj->d.data[handle + 2];
2178 
2179  uint type = flags >> 24;
2180  if (type == 0xff) // special value for QVariant
2181  type = QVariant::LastType;
2182  if (type)
2183  return QVariant::Type(type);
2184  if (isEnumType()) {
2185  int enumMetaTypeId = QMetaType::type(qualifiedName(menum));
2186  if (enumMetaTypeId == 0)
2187  return QVariant::Int;
2188  }
2189 #ifdef QT_COORD_TYPE
2190  // qreal metatype must be resolved at runtime.
2191  if (strcmp(typeName(), "qreal") == 0)
2192  return QVariant::Type(qMetaTypeId<qreal>());
2193 #endif
2194 
2195  return QVariant::UserType;
2196 }
2197 
2211 {
2212  QVariant::Type tp = type();
2213  if (tp != QVariant::UserType)
2214  return tp;
2215  if (isEnumType()) {
2216  int enumMetaTypeId = QMetaType::type(qualifiedName(menum));
2217  return enumMetaTypeId;
2218  }
2219  return QMetaType::type(typeName());
2220 }
2221 
2231 {
2232  if (!mobj)
2233  return -1;
2234  return idx + mobj->propertyOffset();
2235 }
2236 
2248 {
2249  return isEnumType() && menum.isFlag();
2250 }
2251 
2259 {
2260  if (!mobj)
2261  return false;
2262  int handle = priv(mobj->d.data)->propertyData + 3*idx;
2263  int flags = mobj->d.data[handle + 2];
2264  return (flags & EnumOrFlag) && menum.name();
2265 }
2266 
2280 {
2281  if (!mobj)
2282  return false;
2283  int handle = priv(mobj->d.data)->propertyData + 3*idx;
2284  int flags = mobj->d.data[handle + 2];
2285  return (flags & StdCppSet);
2286 }
2287 
2295 {
2296  return menum;
2297 }
2298 
2306 {
2307  if (!object || !mobj)
2308  return QVariant();
2309 
2310  uint t = QVariant::Int;
2311  if (isEnumType()) {
2312  /*
2313  try to create a QVariant that can be converted to this enum
2314  type (only works if the enum has already been registered
2315  with QMetaType)
2316  */
2317  int enumMetaTypeId = QMetaType::type(qualifiedName(menum));
2318  if (enumMetaTypeId != 0)
2319  t = enumMetaTypeId;
2320  } else {
2321  int handle = priv(mobj->d.data)->propertyData + 3*idx;
2322  uint flags = mobj->d.data[handle + 2];
2323  const char *typeName = mobj->d.stringdata + mobj->d.data[handle + 1];
2324  t = (flags >> 24);
2325  if (t == 0xff) // special value for QVariant
2326  t = QVariant::LastType;
2327  if (t == QVariant::Invalid)
2328  t = QMetaType::type(typeName);
2329  if (t == QVariant::Invalid)
2330  t = QVariant::nameToType(typeName);
2331  if (t == QVariant::Invalid || t == QVariant::UserType) {
2332  if (t == QVariant::Invalid)
2333  qWarning("QMetaProperty::read: Unable to handle unregistered datatype '%s' for property '%s::%s'", typeName, mobj->className(), name());
2334  return QVariant();
2335  }
2336  }
2337 
2338  // the status variable is changed by qt_metacall to indicate what it did
2339  // this feature is currently only used by QtDBus and should not be depended
2340  // upon. Don't change it without looking into QDBusAbstractInterface first
2341  // -1 (unchanged): normal qt_metacall, result stored in argv[0]
2342  // changed: result stored directly in value
2343  int status = -1;
2344  QVariant value;
2345  void *argv[] = { 0, &value, &status };
2346  if (t == QVariant::LastType) {
2347  argv[0] = &value;
2348  } else {
2349  value = QVariant(t, (void*)0);
2350  argv[0] = value.data();
2351  }
2352  QMetaObject::metacall(const_cast<QObject*>(object), QMetaObject::ReadProperty,
2353  idx + mobj->propertyOffset(), argv);
2354 
2355  if (status != -1)
2356  return value;
2357  if (t != QVariant::LastType && argv[0] != value.data())
2358  // pointer or reference
2359  return QVariant((QVariant::Type)t, argv[0]);
2360  return value;
2361 }
2362 
2369 bool QMetaProperty::write(QObject *object, const QVariant &value) const
2370 {
2371  if (!object || !isWritable())
2372  return false;
2373 
2374  QVariant v = value;
2375  uint t = QVariant::Invalid;
2376  if (isEnumType()) {
2377  if (v.type() == QVariant::String
2378 #ifdef QT3_SUPPORT
2379  || v.type() == QVariant::CString
2380 #endif
2381  ) {
2382  if (isFlagType())
2383  v = QVariant(menum.keysToValue(value.toByteArray()));
2384  else
2385  v = QVariant(menum.keyToValue(value.toByteArray()));
2386  } else if (v.type() != QVariant::Int && v.type() != QVariant::UInt) {
2387  int enumMetaTypeId = QMetaType::type(qualifiedName(menum));
2388  if ((enumMetaTypeId == 0) || (v.userType() != enumMetaTypeId) || !v.constData())
2389  return false;
2390  v = QVariant(*reinterpret_cast<const int *>(v.constData()));
2391  }
2393  } else {
2394  int handle = priv(mobj->d.data)->propertyData + 3*idx;
2395  uint flags = mobj->d.data[handle + 2];
2396  t = flags >> 24;
2397  if (t == 0xff) // special value for QVariant
2398  t = QVariant::LastType;
2399  if (t == QVariant::Invalid) {
2400  const char *typeName = mobj->d.stringdata + mobj->d.data[handle + 1];
2401  const char *vtypeName = value.typeName();
2402  if (vtypeName && strcmp(typeName, vtypeName) == 0)
2403  t = value.userType();
2404  else
2405  t = QVariant::nameToType(typeName);
2406  }
2407  if (t == QVariant::Invalid)
2408  return false;
2409  if (t != QVariant::LastType && t != (uint)value.userType() && (t < QMetaType::User && !v.convert((QVariant::Type)t)))
2410  return false;
2411  }
2412 
2413  // the status variable is changed by qt_metacall to indicate what it did
2414  // this feature is currently only used by QtDBus and should not be depended
2415  // upon. Don't change it without looking into QDBusAbstractInterface first
2416  // -1 (unchanged): normal qt_metacall, result stored in argv[0]
2417  // changed: result stored directly in value, return the value of status
2418  int status = -1;
2419  // the flags variable is used by the declarative module to implement
2420  // interception of property writes.
2421  int flags = 0;
2422  void *argv[] = { 0, &v, &status, &flags };
2423  if (t == QVariant::LastType)
2424  argv[0] = &v;
2425  else
2426  argv[0] = v.data();
2428  return status;
2429 }
2430 
2439 bool QMetaProperty::reset(QObject *object) const
2440 {
2441  if (!object || !mobj || !isResettable())
2442  return false;
2443  void *argv[] = { 0 };
2445  return true;
2446 }
2447 
2455 {
2456  if (!mobj)
2457  return false;
2458  int flags = mobj->d.data[handle + 2];
2459  return flags & Resettable;
2460 }
2461 
2468 {
2469  if (!mobj)
2470  return false;
2471  int flags = mobj->d.data[handle + 2];
2472  return flags & Readable;
2473 }
2474 
2482 {
2483  if (!mobj)
2484  return false;
2485  int flags = mobj->d.data[handle + 2];
2486  return flags & Notify;
2487 }
2488 
2501 {
2502  int id = notifySignalIndex();
2503  if (id != -1)
2504  return mobj->method(id);
2505  else
2506  return QMetaMethod();
2507 }
2508 
2521 {
2522  if (hasNotifySignal()) {
2523  int offset = priv(mobj->d.data)->propertyData +
2524  priv(mobj->d.data)->propertyCount * 3 + idx;
2525  return mobj->d.data[offset] + mobj->methodOffset();
2526  } else {
2527  return -1;
2528  }
2529 }
2530 
2541 {
2542  if (!mobj)
2543  return 0;
2544  int flags = mobj->d.data[handle + 2];
2545  if (flags & Revisioned) {
2546  int offset = priv(mobj->d.data)->propertyData +
2547  priv(mobj->d.data)->propertyCount * 3 + idx;
2548  // Revision data is placed after NOTIFY data, if present.
2549  // Iterate through properties to discover whether we have NOTIFY signals.
2550  for (int i = 0; i < priv(mobj->d.data)->propertyCount; ++i) {
2551  int handle = priv(mobj->d.data)->propertyData + 3*i;
2552  if (mobj->d.data[handle + 2] & Notify) {
2553  offset += priv(mobj->d.data)->propertyCount;
2554  break;
2555  }
2556  }
2557  return mobj->d.data[offset];
2558  } else {
2559  return 0;
2560  }
2561 }
2562 
2570 {
2571  if (!mobj)
2572  return false;
2573  int flags = mobj->d.data[handle + 2];
2574  return flags & Writable;
2575 }
2576 
2577 
2587 bool QMetaProperty::isDesignable(const QObject *object) const
2588 {
2589  if (!mobj)
2590  return false;
2591  int flags = mobj->d.data[handle + 2];
2592  bool b = flags & Designable;
2593  if (object) {
2594  void *argv[] = { &b };
2595  QMetaObject::metacall(const_cast<QObject*>(object), QMetaObject::QueryPropertyDesignable,
2596  idx + mobj->propertyOffset(), argv);
2597  }
2598  return b;
2599 
2600 
2601 }
2602 
2612 bool QMetaProperty::isScriptable(const QObject *object) const
2613 {
2614  if (!mobj)
2615  return false;
2616  int flags = mobj->d.data[handle + 2];
2617  bool b = flags & Scriptable;
2618  if (object) {
2619  void *argv[] = { &b };
2620  QMetaObject::metacall(const_cast<QObject*>(object), QMetaObject::QueryPropertyScriptable,
2621  idx + mobj->propertyOffset(), argv);
2622  }
2623  return b;
2624 }
2625 
2635 bool QMetaProperty::isStored(const QObject *object) const
2636 {
2637  if (!mobj)
2638  return false;
2639  int flags = mobj->d.data[handle + 2];
2640  bool b = flags & Stored;
2641  if (object) {
2642  void *argv[] = { &b };
2643  QMetaObject::metacall(const_cast<QObject*>(object), QMetaObject::QueryPropertyStored,
2644  idx + mobj->propertyOffset(), argv);
2645  }
2646  return b;
2647 }
2648 
2659 bool QMetaProperty::isUser(const QObject *object) const
2660 {
2661  if (!mobj)
2662  return false;
2663  int flags = mobj->d.data[handle + 2];
2664  bool b = flags & User;
2665  if (object) {
2666  void *argv[] = { &b };
2667  QMetaObject::metacall(const_cast<QObject*>(object), QMetaObject::QueryPropertyUser,
2668  idx + mobj->propertyOffset(), argv);
2669  }
2670  return b;
2671 }
2672 
2883 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static int indexOfMethodRelative(const QMetaObject **baseObject, const char *method, bool normalizeStringData)
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const T * constData() const
int type
Definition: qmetatype.cpp:239
void truncate(int pos)
Truncates the byte array at index position pos.
bool isScriptable(const QObject *obj=0) const
Returns true if the property is scriptable for the given object; otherwise returns false...
bool isWritable() const
Returns true if this property is writable; otherwise returns false.
unsigned char c[8]
Definition: qnumeric_p.h:62
The QMetaEnum class provides meta-data about an enumerator.
Definition: qmetaobject.h:147
static char * qNormalizeType(char *d, int &templdepth, QByteArray &result)
void * data() const
Returns the data set in the constructor.
Definition: qobjectdefs.h:261
The QSemaphore class provides a general counting semaphore.
Definition: qsemaphore.h:57
int keysToValue(const char *keys) const
Returns the value derived from combining together the values of the keys using the OR operator...
virtual int createProperty(const char *, const char *)
Definition: qobject_p.h:337
static bool is_ident_char(char s)
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
int methodIndex() const
Returns this method&#39;s index.
bool isUser(const QObject *obj=0) const
Returns true if this property is designated as the USER property, i.e., the one that the user can edi...
int notifySignalIndex() const
Returns the index of the property change notifying signal if one was specified, otherwise returns -1...
QByteArray & append(char c)
Appends the character ch to this byte array.
bool isValid() const
Returns true if this enum is valid (has a name); otherwise returns false.
Definition: qmetaobject.h:168
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
Data * d
Definition: qbytearray.h:386
static int metacall(QObject *, Call, int, void **)
QByteArray valueToKeys(int value) const
Returns a byte array of &#39;|&#39;-separated keys that represents the given value.
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int static_metacall(Call, int, void **) const
const char * valueToKey(int value) const
Returns the string that is used as the name of the given enumeration value, or 0 if value is not defi...
int indexOfConstructor(const char *constructor) const
Finds constructor and returns its index; otherwise returns -1.
Access
This enum describes the access level of a method, following the conventions used in C++...
Definition: qmetaobject.h:66
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
const char * key(int index) const
Returns the key with the given index, or 0 if no such key exists.
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
int enumeratorOffset() const
Returns the enumerator offset for this class; i.e.
int constructorCount() const
Returns the number of constructors in this class.
int propertyCount() const
Returns the number of properties in this class, including the number of properties provided by each b...
The QString class provides a Unicode character string.
Definition: qstring.h:83
static int indexOfSignalRelative(const QMetaObject **baseObject, const char *name, bool normalizeStringData)
Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object...
const char * typeName() const
Returns the return type of this method, or an empty string if the return type is void.
const char * stringdata
Definition: qobjectdefs.h:470
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
const char * scope() const
Returns the scope this enumerator was declared in.
The QGenericReturnArgument class is an internal helper class for marshalling arguments.
Definition: qobjectdefs.h:269
int indexOfProperty(const char *name) const
Finds property name and returns its index; otherwise returns -1.
int propertyIndex() const
Returns this property&#39;s index.
void append(const T &t)
const char * name() const
Returns the name of the enumerator (without the scope).
static QByteArray qualifiedName(const QMetaEnum &e)
QStringList keys
static void * construct(int type, const void *copy=0)
Returns a copy of copy, assuming it is of type type.
Definition: qmetatype.cpp:1042
const QMetaObject &(* QMetaObjectAccessor)()
Definition: qobjectdefs.h:476
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
bool reset(QObject *obj) const
Resets the property for the given object with a reset method.
QObject * cast(QObject *obj) const
Returns obj if object obj inherits from this meta-object; otherwise returns 0.
The QGenericArgument class is an internal helper class for marshalling arguments. ...
Definition: qobjectdefs.h:256
static bool is_space(char s)
ConnectionType
Definition: qnamespace.h:1469
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
void * data()
Definition: qvariant.cpp:3077
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
bool isEnumType() const
Returns true if the property&#39;s type is an enumeration value; otherwise returns false.
int lastIndexOf(char c, int from=-1) const
Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from.
QList< QByteArray > parameterNames() const
Returns a list of parameter names.
int methodOffset() const
Returns the method offset for this class; i.e.
int userType() const
Returns this property&#39;s user type.
bool isFlagType() const
Returns true if the property&#39;s type is an enumeration value that is used as a flag; otherwise returns...
const char * typeName
Definition: qmetatype.cpp:239
void(* StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **)
Definition: qobject_p.h:113
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
QMetaMethod notifySignal() const
Returns the QMetaMethod instance of the property change notifying signal if one was specified...
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
QObject * newInstance(QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument()) const
Constructs a new instance of this class.
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
static void destroy(int type, void *data)
Destroys the data, assuming it is of the type given.
Definition: qmetatype.cpp:1263
int enumeratorCount() const
Returns the number of enumerators in this class.
static bool checkConnectArgs(const char *signal, const char *method)
Returns true if the signal and method arguments are compatible; otherwise returns false...
uint handle
Definition: qmetaobject.h:171
int indexOfSlot(const char *slot) const
Finds slot and returns its index; otherwise returns -1.
int indexOfSignal(const char *signal) const
Finds signal and returns its index; otherwise returns -1.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
static int type(const char *typeName)
Returns a handle to the type called typeName, or 0 if there is no such type.
Definition: qmetatype.cpp:607
int classInfoCount() const
Returns the number of items of class information in this class.
bool hasStdCppSet() const
Returns true if the property has a C++ setter function that follows Qt&#39;s standard "name" / "setName" ...
const uint * data
Definition: qobjectdefs.h:471
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
const char * typeName() const
Returns the name of the type stored in the variant.
Definition: qvariant.cpp:1984
QListData::Data * d
Definition: qlist.h:118
int keyCount() const
Returns the number of keys.
const QMetaObject * mobj
Definition: qmetaobject.h:170
StaticMetacallFunction static_metacall
Definition: qobjectdefs.h:488
static const QMetaObject * QMetaObject_findMetaObject(const QMetaObject *self, const char *name)
bool convert(Type t)
Casts the variant to the requested type, t.
Definition: qvariant.cpp:2959
bool isResettable() const
Returns true if this property can be reset to a default value; otherwise returns false.
int length() const
Same as size().
Definition: qbytearray.h:356
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
MethodType methodType() const
Returns the type of this method (signal, slot, or method).
uint qstrlen(const char *str)
Definition: qbytearray.h:79
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
QList< QByteArray > parameterTypes() const
Returns a list of parameter types.
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixScope=false, bool adjustConst=true)
bool isFlag() const
Returns true if this enumerator is used as a flag; otherwise returns false.
QString trimmed(QString source)
Definition: generator.cpp:233
const char * name() const
Returns this property&#39;s name.
static const struct @32 types[]
const QMetaObject * mobj
Definition: qmetaobject.h:232
The QMetaClassInfo class provides additional information about a class.
Definition: qmetaobject.h:224
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
const char * tag() const
Returns the tag associated with this method.
static int indexOfSlotRelative(const QMetaObject **m, const char *slot, bool normalizeStringData)
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
int indexOfMethod(const char *method) const
Finds method and returns its index; otherwise returns -1.
QString tr(const char *s, const char *c) const
const void * constData() const
Definition: qvariant.cpp:3065
int key
int classInfoOffset() const
Returns the class information offset for this class; i.e.
const QMetaObject * superdata
Definition: qobjectdefs.h:469
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
bool isStored(const QObject *obj=0) const
Returns true if the property is stored for object; otherwise returns false.
static const QMetaObjectPrivate * priv(const uint *data)
bool isDesignable(const QObject *obj=0) const
Returns true if this property is designable for the given object; otherwise returns false...
QMetaObject * metaObject
Definition: qobject.h:107
struct QMetaObject::@38 d
QVariant read(const QObject *obj) const
Reads the property&#39;s value from the given object.
QFactoryLoader * l
QMetaEnum enumerator(int index) const
Returns the meta-data for the enumerator with the given index.
int keyToValue(const char *key) const
Returns the integer value of the given enumeration key, or -1 if key is not defined.
static const QMetaObject staticQtMetaObject
Definition: qobject.h:322
QMetaEnum enumerator() const
Returns the enumerator if this property&#39;s type is an enumerator type; otherwise the returned value is...
int attributes() const
bool isReadable() const
Returns true if this property is readable; otherwise returns false.
quint16 index
static QByteArray normalizedType(const char *type)
Normalizes a type.
QMetaProperty userProperty() const
Returns the property that has the USER flag set to true.
QScopedPointer< QObjectData > d_ptr
Definition: qobject.h:320
QMetaMethod constructor(int index) const
Returns the meta-data for the constructor with the given index.
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
QMetaEnum menum
Definition: qmetaobject.h:220
int revision() const
Returns the method revision if one was specified by Q_REVISION, otherwise returns 0...
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
const QMetaObject * mobj
Definition: qmetaobject.h:139
int propertyOffset() const
Returns the property offset for this class; i.e.
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
int revision() const
Returns the property revision if one was specified by REVISION, otherwise returns 0...
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419
Access access() const
Returns the access specification of this method (private, protected, or public).
static const QMetaObjectPrivate * get(const QMetaObject *metaobject)
bool write(QObject *obj, const QVariant &value) const
Writes value as the property&#39;s value to the given object.
QString trUtf8(const char *s, const char *c) const
int indexOfEnumerator(const char *name) const
Finds enumerator name and returns its index; otherwise returns -1.
void reserve(int size)
Attempts to allocate memory for at least size bytes.
Definition: qbytearray.h:449
static Type nameToType(const char *name)
Converts the string representation of the storage type given in name, to its enum representation...
Definition: qvariant.cpp:2026
static const KeyPair *const end
bool invoke(QObject *object, Qt::ConnectionType connectionType, QGenericReturnArgument returnValue, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument()) const
Invokes this method on the object object.
bool hasNotifySignal() const
Returns true if this property has a corresponding change notify signal; otherwise returns false...
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
The QThread class provides a platform-independent way to manage threads.
Definition: qthread.h:59
static void qRemoveWhitespace(const char *s, char *d)
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
const QMetaObject ** objects
Definition: qobjectdefs.h:483
const char * typeName() const
Returns the name of this property&#39;s type.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
QByteArray & remove(int index, int len)
Removes len bytes from the array, starting at index position pos, and returns a reference to the arra...
const QMetaObject * mobj
Definition: qmetaobject.h:217
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.
int size() const
const char * name() const
Returns the name set in the constructor.
Definition: qobjectdefs.h:262
int value(int index) const
Returns the value with the given index; or returns -1 if there is no such value.
QVariant::Type type() const
Returns this property&#39;s type.