Qt 4.8
qdeclarativemetatype.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 QtDeclarative 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 <QtDeclarative/qdeclarativeprivate.h>
43 #include "private/qdeclarativemetatype_p.h"
44 
45 #include "private/qdeclarativeproxymetaobject_p.h"
46 #include "private/qdeclarativecustomparser_p.h"
47 #include "private/qdeclarativeguard_p.h"
48 #include "private/qdeclarativeengine_p.h"
49 #include "private/qdeclarativeitemsmodule_p.h"
50 #include "private/qdeclarativeutilmodule_p.h"
51 
52 #include <QtCore/qdebug.h>
53 #include <QtCore/qstringlist.h>
54 #include <QtCore/qmetaobject.h>
55 #include <QtCore/qbitarray.h>
56 #include <QtCore/qreadwritelock.h>
57 #include <qfileinfo.h>
58 #include <qdir.h>
59 #include <qmetatype.h>
60 #include <qobjectdefs.h>
61 #include <qdatetime.h>
62 #include <qbytearray.h>
63 #include <qreadwritelock.h>
64 #include <qstring.h>
65 #include <qstringlist.h>
66 #include <qvector.h>
67 #include <qlocale.h>
68 #include <QtCore/qcryptographichash.h>
69 #include <QtScript/qscriptvalue.h>
70 
71 #include <ctype.h>
72 
73 #ifdef QT_BOOTSTRAPPED
74 # ifndef QT_NO_GEOM_VARIANT
75 # define QT_NO_GEOM_VARIANT
76 # endif
77 #else
78 # include <qbitarray.h>
79 # include <qurl.h>
80 # include <qvariant.h>
81 #endif
82 
83 #ifndef QT_NO_GEOM_VARIANT
84 # include <qsize.h>
85 # include <qpoint.h>
86 # include <qrect.h>
87 # include <qline.h>
88 # include <qvector3d.h>
89 #endif
90 #define NS(x) QT_PREPEND_NAMESPACE(x)
91 
93 
95 {
99  Ids idToType;
101  Names nameToType;
103  MetaObjects metaObjectToType;
105  StringConverters stringConverters;
106 
107  struct ModuleInfo {
108  ModuleInfo(int major, int minor)
109  : vmajor_min(major), vminor_min(minor), vmajor_max(major), vminor_max(minor) {}
110  ModuleInfo(int major_min, int minor_min, int major_max, int minor_max)
111  : vmajor_min(major_min), vminor_min(minor_min), vmajor_max(major_max), vminor_max(minor_max) {}
114  };
116  ModuleInfoHash modules;
117 
121 
123 };
125 Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock)
126 
128 {
130 };
131 
133 Q_GLOBAL_STATIC(QReadWriteLock, registeredComponentDataLock)
134 
136 {
137  for (int i = 0; i < types.count(); ++i)
138  delete types.at(i);
139 }
140 
142 {
143 public:
145 
146  void init() const;
147 
148  bool m_isInterface : 1;
149  const char *m_iid;
154  int m_typeId; int m_listId;
158 
160  void (*m_newFunc)(void *);
162 
170  QObject *(*m_extFunc)(QObject *);
172  int m_index;
174  mutable volatile bool m_isSetup:1;
175  mutable bool m_haveSuperType : 1;
177 
179 };
180 
182 
184 : m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_revision(0), m_containsRevisionedAttributes(false),
185  m_superType(0), m_allocationSize(0), m_newFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0),
186  m_attachedPropertiesType(0), m_parserStatusCast(-1), m_propertyValueSourceCast(-1),
187  m_propertyValueInterceptorCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0),
188  m_isSetup(false), m_haveSuperType(false)
189 {
190 }
191 
192 
195 {
196  d->m_isInterface = true;
197  d->m_iid = interface.iid;
198  d->m_typeId = interface.typeId;
199  d->m_listId = interface.listId;
200  d->m_newFunc = 0;
201  d->m_index = index;
202  d->m_isSetup = true;
203  d->m_version_maj = 0;
204  d->m_version_min = 0;
205 }
206 
209 {
210  QByteArray name = type.uri;
211  if (type.uri) name += '/';
212  name += type.elementName;
213 
214  d->m_module = type.uri;
215  d->m_name = name;
216  d->m_version_maj = type.versionMajor;
217  d->m_version_min = type.versionMinor;
218  if (type.version >= 1) // revisions added in version 1
219  d->m_revision = type.revision;
220  d->m_typeId = type.typeId;
221  d->m_listId = type.listId;
222  d->m_allocationSize = type.objectSize;
223  d->m_newFunc = type.create;
225  d->m_baseMetaObject = type.metaObject;
230  if (iter == d->m_attachedPropertyIds.end())
232  d->m_attachedPropertiesId = *iter;
233  } else {
235  }
240  d->m_index = index;
241  d->m_customParser = type.customParser;
242 
243  if (type.extensionMetaObject)
245 }
246 
248 {
249  delete d->m_customParser;
250  delete d;
251 }
252 
254 {
255  return d->m_module;
256 }
257 
259 {
260  return d->m_version_maj;
261 }
262 
264 {
265  return d->m_version_min;
266 }
267 
268 bool QDeclarativeType::availableInVersion(int vmajor, int vminor) const
269 {
270  return vmajor > d->m_version_maj || (vmajor == d->m_version_maj && vminor >= d->m_version_min);
271 }
272 
273 bool QDeclarativeType::availableInVersion(const QByteArray &module, int vmajor, int vminor) const
274 {
275  return module == d->m_module && (vmajor > d->m_version_maj || (vmajor == d->m_version_maj && vminor >= d->m_version_min));
276 }
277 
278 // returns the nearest _registered_ super class
280 {
281  if (!d->m_haveSuperType) {
282  const QMetaObject *mo = d->m_baseMetaObject->superClass();
283  while (mo && !d->m_superType) {
285  mo = mo->superClass();
286  }
287  d->m_haveSuperType = true;
288  }
289 
290  return d->m_superType;
291 }
292 
293 static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
294  const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd)
295 {
296  // Clone Q_CLASSINFO
297  for (int ii = mo->classInfoOffset(); ii < mo->classInfoCount(); ++ii) {
298  QMetaClassInfo info = mo->classInfo(ii);
299 
300  int otherIndex = ignoreEnd->indexOfClassInfo(info.name());
301  if (otherIndex >= ignoreStart->classInfoOffset() + ignoreStart->classInfoCount()) {
302  // Skip
303  } else {
304  builder.addClassInfo(info.name(), info.value());
305  }
306  }
307 
308  // Clone int ii;; ii < mo->propertyCount(); ++ii) {
309  QMetaProperty property = mo->property(ii);
310 
311  int otherIndex = ignoreEnd->indexOfProperty(property.name());
312  if (otherIndex >= ignoreStart->propertyOffset() + ignoreStart->propertyCount()) {
313  builder.addProperty(QByteArray("__qml_ignore__") + property.name(), QByteArray("void"));
314  // Skip
315  } else {
316  builder.addProperty(property);
317  }
318  }
319 
320  // Clone Q_METHODS
321  for (int ii = mo->methodOffset(); ii < mo->methodCount(); ++ii) {
322  QMetaMethod method = mo->method(ii);
323 
324  // More complex - need to search name
325  QByteArray name = method.signature();
326  int parenIdx = name.indexOf('(');
327  if (parenIdx != -1) name = name.left(parenIdx);
328 
329 
330  bool found = false;
331 
332  for (int ii = ignoreStart->methodOffset() + ignoreStart->methodCount();
333  !found && ii < ignoreEnd->methodOffset() + ignoreEnd->methodCount();
334  ++ii) {
335 
336  QMetaMethod other = ignoreEnd->method(ii);
337  QByteArray othername = other.signature();
338  int parenIdx = othername.indexOf('(');
339  if (parenIdx != -1) othername = othername.left(parenIdx);
340 
341  found = name == othername;
342  }
343 
344  QMetaMethodBuilder m = builder.addMethod(method);
345  if (found) // SKIP
347  }
348 
349  // Clone Q_ENUMS
350  for (int ii = mo->enumeratorOffset(); ii < mo->enumeratorCount(); ++ii) {
351  QMetaEnum enumerator = mo->enumerator(ii);
352 
353  int otherIndex = ignoreEnd->indexOfEnumerator(enumerator.name());
354  if (otherIndex >= ignoreStart->enumeratorOffset() + ignoreStart->enumeratorCount()) {
355  // Skip
356  } else {
357  builder.addEnumerator(enumerator);
358  }
359  }
360 }
361 
363 {
364  if (m_isSetup) return;
365 
366  QWriteLocker lock(metaTypeDataLock());
367  if (m_isSetup)
368  return;
369 
370  // Setup extended meta object
371  // XXX - very inefficient
372  const QMetaObject *mo = m_baseMetaObject;
373  if (m_extFunc) {
374  QMetaObject *mmo = new QMetaObject;
375  *mmo = *m_extMetaObject;
376  mmo->d.superdata = mo;
377  QDeclarativeProxyMetaObject::ProxyData data = { mmo, m_extFunc, 0, 0 };
378  m_metaObjects << data;
379  }
380 
381  mo = mo->d.superdata;
382  while(mo) {
383  QDeclarativeType *t = metaTypeData()->metaObjectToType.value(mo);
384  if (t) {
385  if (t->d->m_extFunc) {
386  QMetaObjectBuilder builder;
387  clone(builder, t->d->m_extMetaObject, t->d->m_baseMetaObject, m_baseMetaObject);
388  QMetaObject *mmo = builder.toMetaObject();
389  mmo->d.superdata = m_baseMetaObject;
390  if (!m_metaObjects.isEmpty())
391  m_metaObjects.last().metaObject->d.superdata = mmo;
393  m_metaObjects << data;
394  }
395  }
396  mo = mo->d.superdata;
397  }
398 
399  for (int ii = 0; ii < m_metaObjects.count(); ++ii) {
400  m_metaObjects[ii].propertyOffset =
401  m_metaObjects.at(ii).metaObject->propertyOffset();
402  m_metaObjects[ii].methodOffset =
403  m_metaObjects.at(ii).metaObject->methodOffset();
404  }
405 
406  // Check for revisioned details
407  {
408  const QMetaObject *mo = 0;
409  if (m_metaObjects.isEmpty())
410  mo = m_baseMetaObject;
411  else
412  mo = m_metaObjects.first().metaObject;
413 
414  for (int ii = 0; !m_containsRevisionedAttributes && ii < mo->propertyCount(); ++ii) {
415  if (mo->property(ii).revision() != 0)
416  m_containsRevisionedAttributes = true;
417  }
418 
419  for (int ii = 0; !m_containsRevisionedAttributes && ii < mo->methodCount(); ++ii) {
420  if (mo->method(ii).revision() != 0)
421  m_containsRevisionedAttributes = true;
422  }
423  }
424 
425  m_isSetup = true;
426  lock.unlock();
427 }
428 
430 {
431  if (d->m_baseMetaObject)
432  return d->m_baseMetaObject->className();
433  else
434  return QByteArray();
435 }
436 
438 {
439  return d->m_name;
440 }
441 
443 {
444  d->init();
445 
446  QObject *rv = (QObject *)operator new(d->m_allocationSize);
447  d->m_newFunc(rv);
448 
449  if (rv && !d->m_metaObjects.isEmpty())
451 
452  return rv;
453 }
454 
455 void QDeclarativeType::create(QObject **out, void **memory, size_t additionalMemory) const
456 {
457  d->init();
458 
459  QObject *rv = (QObject *)operator new(d->m_allocationSize + additionalMemory);
460  d->m_newFunc(rv);
461 
462  if (rv && !d->m_metaObjects.isEmpty())
464 
465  *out = rv;
466  *memory = ((char *)rv) + d->m_allocationSize;
467 }
468 
470 {
471  return d->m_customParser;
472 }
473 
475 {
476  return d->m_newFunc;
477 }
478 
480 {
481  return d->m_noCreationReason;
482 }
483 
485 {
486  return d->m_allocationSize;
487 }
488 
490 {
491  return d->m_newFunc != 0;
492 }
493 
495 {
496  d->init();
497 
498  return !d->m_metaObjects.isEmpty();
499 }
500 
502 {
503  return d->m_isInterface;
504 }
505 
507 {
508  return d->m_typeId;
509 }
510 
512 {
513  return d->m_listId;
514 }
515 
517 {
518  d->init();
519 
520  if (d->m_metaObjects.isEmpty())
521  return d->m_baseMetaObject;
522  else
523  return d->m_metaObjects.first().metaObject;
524 
525 }
526 
528 {
529  return d->m_baseMetaObject;
530 }
531 
533 {
534  d->init();
535 
537 }
538 
540 {
541  return d->m_revision;
542 }
543 
545 {
546  return d->m_attachedPropertiesFunc;
547 }
548 
550 {
551  return d->m_attachedPropertiesType;
552 }
553 
554 /*
555 This is the id passed to qmlAttachedPropertiesById(). This is different from the index
556 for the case that a single class is registered under two or more names (eg. Item in
557 Qt 4.7 and QtQuick 1.0).
558 */
560 {
561  return d->m_attachedPropertiesId;
562 }
563 
565 {
566  return d->m_parserStatusCast;
567 }
568 
570 {
572 }
573 
575 {
577 }
578 
580 {
581  return d->m_iid;
582 }
583 
585 {
586  return d->m_index;
587 }
588 
590 {
591  QWriteLocker lock(metaTypeDataLock());
592  QDeclarativeMetaTypeData *data = metaTypeData();
593 
594  data->parentFunctions.append(autoparent.function);
595 
596  return data->parentFunctions.count() - 1;
597 }
598 
600 {
601  if (interface.version > 0)
602  qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
603 
604  QWriteLocker lock(metaTypeDataLock());
605  QDeclarativeMetaTypeData *data = metaTypeData();
606 
607  int index = data->types.count();
608 
609  QDeclarativeType *type = new QDeclarativeType(index, interface);
610 
611  data->types.append(type);
612  data->idToType.insert(type->typeId(), type);
613  data->idToType.insert(type->qListTypeId(), type);
614  // XXX No insertMulti, so no multi-version interfaces?
615  if (!type->qmlTypeName().isEmpty())
616  data->nameToType.insert(type->qmlTypeName(), type);
617 
618  if (data->interfaces.size() <= interface.typeId)
619  data->interfaces.resize(interface.typeId + 16);
620  if (data->lists.size() <= interface.listId)
621  data->lists.resize(interface.listId + 16);
622  data->interfaces.setBit(interface.typeId, true);
623  data->lists.setBit(interface.listId, true);
624 
625  return index;
626 }
627 
629 {
630  if (type.elementName) {
631  for (int ii = 0; type.elementName[ii]; ++ii) {
632  if (!isalnum(type.elementName[ii])) {
633  qWarning("qmlRegisterType(): Invalid QML element name \"%s\"", type.elementName);
634  return -1;
635  }
636  }
637  }
638 
639  QWriteLocker lock(metaTypeDataLock());
640  QDeclarativeMetaTypeData *data = metaTypeData();
641  int index = data->types.count();
642 
643  QDeclarativeType *dtype = new QDeclarativeType(index, type);
644 
645  data->types.append(dtype);
646  data->idToType.insert(dtype->typeId(), dtype);
647  if (dtype->qListTypeId()) data->idToType.insert(dtype->qListTypeId(), dtype);
648 
649  if (!dtype->qmlTypeName().isEmpty())
650  data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
651 
652  data->metaObjectToType.insertMulti(dtype->baseMetaObject(), dtype);
653 
654  if (data->objects.size() <= type.typeId)
655  data->objects.resize(type.typeId + 16);
656  if (data->lists.size() <= type.listId)
657  data->lists.resize(type.listId + 16);
658  data->objects.setBit(type.typeId, true);
659  if (type.listId) data->lists.setBit(type.listId, true);
660 
661  if (type.uri) {
662  QByteArray mod(type.uri);
664  if (it == data->modules.end()) {
665  // New module
667  } else if ((*it).vmajor_max < type.versionMajor || ((*it).vmajor_max == type.versionMajor && (*it).vminor_max < type.versionMinor)) {
668  // Newer module
669  data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo((*it).vmajor_min, (*it).vminor_min, type.versionMajor, type.versionMinor));
670  } else if ((*it).vmajor_min > type.versionMajor || ((*it).vmajor_min == type.versionMajor && (*it).vminor_min > type.versionMinor)) {
671  // Older module
672  data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo(type.versionMajor, type.versionMinor, (*it).vmajor_min, (*it).vminor_min));
673  }
674  }
675 
676  return index;
677 }
678 
680 {
681  if (data.typeName) {
682  for (int ii = 0; data.typeName[ii]; ++ii) {
683  if (!isalnum(data.typeName[ii])) {
684  qWarning("qmlRegisterType(): Invalid QML type name \"%s\"", data.typeName);
685  return 0;
686  }
687  }
688  } else {
689  qWarning("qmlRegisterType(): No QML type name for \"%s\"", data.url.toString().toLatin1().constData());
690  return 0;
691  }
692 
693  QWriteLocker lock(registeredComponentDataLock());
694  QString path;
695  // Relative paths are relative to application working directory
696  if (data.url.isRelative() || data.url.scheme() == QLatin1String("file")) // Workaround QTBUG-11929
697  path = QUrl::fromLocalFile(QDir::currentPath()+QLatin1String("/")).resolved(data.url).toString();
698  else
699  path = data.url.toString();
700  QDeclarativeRegisteredComponentData *d = registeredComponentData();
703  path,
704  data.majorVersion,
705  data.minorVersion
706  );
707 
708  QDeclarativeDirComponents* comps = d->registeredComponents.value(QByteArray(data.uri), 0);
709  if (!comps)
710  d->registeredComponents.insert(QByteArray(data.uri), comps = new QDeclarativeDirComponents);
711 
712  // Types added later should take precedence, like registerType
713  comps->prepend(comp);
714 
715  return 1;
716 }
717 
718 /*
719 This method is "over generalized" to allow us to (potentially) register more types of things in
720 the future without adding exported symbols.
721 */
723 {
724  if (type == TypeRegistration) {
725  return registerType(*reinterpret_cast<RegisterType *>(data));
726  } else if (type == InterfaceRegistration) {
727  return registerInterface(*reinterpret_cast<RegisterInterface *>(data));
728  } else if (type == AutoParentRegistration) {
729  return registerAutoParentFunction(*reinterpret_cast<RegisterAutoParent *>(data));
730  } else if (type == ComponentRegistration) {
731  return registerComponent(*reinterpret_cast<RegisterComponent *>(data));
732  }
733  return -1;
734 }
735 
736 /*
737  Have any types been registered for \a module with at least versionMajor.versionMinor, and types
738  for \a module with at most versionMajor.versionMinor.
739 
740  So if only 4.7 and 4.9 have been registered, 4.7,4.8, and 4.9 are valid, but not 4.6 nor 4.10.
741 
742  Passing -1 for both \a versionMajor \a versionMinor will return true if any version is installed.
743 */
744 bool QDeclarativeMetaType::isModule(const QByteArray &module, int versionMajor, int versionMinor)
745 {
746 #ifndef QT_NO_IMPORT_QT47_QML
747  // "import Qt 4.7" should have died off, but unfortunately, it was in a
748  // major release. We don't register 4.7 types by default, as it's a
749  // performance penalty. Instead, register them on-demand.
750  if (strcmp(module.constData(), "Qt") == 0 && versionMajor == 4 && versionMinor == 7) {
751  static bool qt47Registered = false;
752  if (!qt47Registered) {
753  qWarning() << Q_FUNC_INFO << "Qt 4.7 import detected; please note that Qt 4.7 is directly reusable as QtQuick 1.x with no code changes. Continuing, but startup time will be slower.";
754  qt47Registered = true;
759  }
760  }
761 #endif
762 
763  QDeclarativeMetaTypeData *data = metaTypeData();
765  return it != data->modules.end()
766  && ((versionMajor<0 && versionMinor<0) ||
767  (((*it).vmajor_max > versionMajor ||
768  ((*it).vmajor_max == versionMajor && (*it).vminor_max >= versionMinor))
769  && ((*it).vmajor_min < versionMajor ||
770  ((*it).vmajor_min == versionMajor && (*it).vminor_min <= versionMinor))));
771 }
772 
774 {
775  QReadLocker lock(metaTypeDataLock());
776  QDeclarativeMetaTypeData *data = metaTypeData();
777  return data->parentFunctions;
778 }
779 
781 {
782  if (!isQObject(v.userType())) {
783  if (ok) *ok = false;
784  return 0;
785  }
786 
787  if (ok) *ok = true;
788 
789  return *(QObject **)v.constData();
790 }
791 
793 {
794  if (userType == QMetaType::QObjectStar)
795  return true;
796 
797  QReadLocker lock(metaTypeDataLock());
798  QDeclarativeMetaTypeData *data = metaTypeData();
799  return userType >= 0 && userType < data->objects.size() && data->objects.testBit(userType);
800 }
801 
802 /*
803  Returns the item type for a list of type \a id.
804  */
806 {
807  QReadLocker lock(metaTypeDataLock());
808  QDeclarativeMetaTypeData *data = metaTypeData();
809  QDeclarativeType *type = data->idToType.value(id);
810  if (type && type->qListTypeId() == id)
811  return type->typeId();
812  else
813  return 0;
814 }
815 
817 {
818  QReadLocker lock(metaTypeDataLock());
819  QDeclarativeMetaTypeData *data = metaTypeData();
820 
822  if (type && type->attachedPropertiesFunction())
823  return type->attachedPropertiesId();
824  else
825  return -1;
826 }
827 
829 {
830  if (id < 0)
831  return 0;
832  QReadLocker lock(metaTypeDataLock());
833  QDeclarativeMetaTypeData *data = metaTypeData();
834  return data->types.at(id)->attachedPropertiesFunction();
835 }
836 
838 {
839  int idx = metaObject->indexOfClassInfo("DefaultProperty");
840  if (-1 == idx)
841  return QMetaProperty();
842 
843  QMetaClassInfo info = metaObject->classInfo(idx);
844  if (!info.value())
845  return QMetaProperty();
846 
847  idx = metaObject->indexOfProperty(info.value());
848  if (-1 == idx)
849  return QMetaProperty();
850 
851  return metaObject->property(idx);
852 }
853 
855 {
856  if (!obj)
857  return QMetaProperty();
858 
859  const QMetaObject *metaObject = obj->metaObject();
860  return defaultProperty(metaObject);
861 }
862 
864 {
865  int idx = metaObject->indexOfClassInfo("DefaultMethod");
866  if (-1 == idx)
867  return QMetaMethod();
868 
869  QMetaClassInfo info = metaObject->classInfo(idx);
870  if (!info.value())
871  return QMetaMethod();
872 
873  idx = metaObject->indexOfMethod(info.value());
874  if (-1 == idx)
875  return QMetaMethod();
876 
877  return metaObject->method(idx);
878 }
879 
881 {
882  if (!obj)
883  return QMetaMethod();
884 
885  const QMetaObject *metaObject = obj->metaObject();
886  return defaultMethod(metaObject);
887 }
888 
890 {
891  if (userType < 0)
892  return Unknown;
893  if (userType == QMetaType::QObjectStar)
894  return Object;
895 
896  QReadLocker lock(metaTypeDataLock());
897  QDeclarativeMetaTypeData *data = metaTypeData();
898  if (userType < data->objects.size() && data->objects.testBit(userType))
899  return Object;
900  else if (userType < data->lists.size() && data->lists.testBit(userType))
901  return List;
902  else
903  return Unknown;
904 }
905 
907 {
908  QReadLocker lock(metaTypeDataLock());
909  QDeclarativeMetaTypeData *data = metaTypeData();
910  return userType >= 0 && userType < data->interfaces.size() && data->interfaces.testBit(userType);
911 }
912 
913 const char *QDeclarativeMetaType::interfaceIId(int userType)
914 {
915  QReadLocker lock(metaTypeDataLock());
916  QDeclarativeMetaTypeData *data = metaTypeData();
917  QDeclarativeType *type = data->idToType.value(userType);
918  lock.unlock();
919  if (type && type->isInterface() && type->typeId() == userType)
920  return type->interfaceIId();
921  else
922  return 0;
923 }
924 
926 {
927  QReadLocker lock(metaTypeDataLock());
928  QDeclarativeMetaTypeData *data = metaTypeData();
929  return userType >= 0 && userType < data->lists.size() && data->lists.testBit(userType);
930 }
931 
947 void QDeclarativeMetaType::registerCustomStringConverter(int type, StringConverter converter)
948 {
949  QWriteLocker lock(metaTypeDataLock());
950 
951  QDeclarativeMetaTypeData *data = metaTypeData();
952  if (data->stringConverters.contains(type))
953  return;
954  data->stringConverters.insert(type, converter);
955 }
956 
962 {
963  QReadLocker lock(metaTypeDataLock());
964 
965  QDeclarativeMetaTypeData *data = metaTypeData();
966  return data->stringConverters.value(type);
967 }
968 
973 QDeclarativeType *QDeclarativeMetaType::qmlType(const QByteArray &name, int version_major, int version_minor)
974 {
975  QReadLocker lock(metaTypeDataLock());
976  QDeclarativeMetaTypeData *data = metaTypeData();
977 
979  foreach (QDeclarativeType *t, types) {
980  // XXX version_major<0 just a kludge for QDeclarativePropertyPrivate::initProperty
981  if (version_major<0 || t->availableInVersion(version_major,version_minor))
982  return t;
983  }
984  return 0;
985 }
986 
992 {
993  QReadLocker lock(metaTypeDataLock());
994  QDeclarativeMetaTypeData *data = metaTypeData();
995 
996  return data->metaObjectToType.value(metaObject);
997 }
998 
1004 QDeclarativeType *QDeclarativeMetaType::qmlType(const QMetaObject *metaObject, const QByteArray &module, int version_major, int version_minor)
1005 {
1006  QReadLocker lock(metaTypeDataLock());
1007  QDeclarativeMetaTypeData *data = metaTypeData();
1008 
1010  while (it != data->metaObjectToType.end() && it.key() == metaObject) {
1011  QDeclarativeType *t = *it;
1012  if (version_major < 0 || t->availableInVersion(module, version_major,version_minor))
1013  return t;
1014  ++it;
1015  }
1016 
1017  return 0;
1018 }
1019 
1025 {
1026  QReadLocker lock(metaTypeDataLock());
1027  QDeclarativeMetaTypeData *data = metaTypeData();
1028 
1029  QDeclarativeType *type = data->idToType.value(userType);
1030  if (type && type->typeId() == userType)
1031  return type;
1032  else
1033  return 0;
1034 }
1035 
1041 {
1042  QReadLocker lock(registeredComponentDataLock());
1043  QDeclarativeRegisteredComponentData *data = registeredComponentData();
1044 
1045  QDeclarativeDirComponents* comps = data->registeredComponents.value(module, 0);
1046  if (!comps)
1047  return QDeclarativeDirComponents();
1048  QDeclarativeDirComponents ret = *comps;
1049  for (int i = ret.count() - 1; i >= 0; i--) {
1051  if (version_major >= 0 && (c.majorVersion != version_major || c.minorVersion > version_minor))
1052  ret.removeAt(i);
1053  }
1054 
1055  return ret;
1056 }
1057 
1058 
1063 {
1064  QReadLocker lock(metaTypeDataLock());
1065  QDeclarativeMetaTypeData *data = metaTypeData();
1066 
1067  return data->nameToType.keys();
1068 }
1069 
1074 {
1075  QReadLocker lock(metaTypeDataLock());
1076  QDeclarativeMetaTypeData *data = metaTypeData();
1077 
1078  return data->nameToType.values();
1079 }
1080 
1082 
1083 #include <QtGui/qfont.h>
1084 #include <QtGui/qpixmap.h>
1085 #include <QtGui/qbrush.h>
1086 #include <QtGui/qcolor.h>
1087 #include <QtGui/qpalette.h>
1088 #include <QtGui/qicon.h>
1089 #include <QtGui/qimage.h>
1090 #include <QtGui/qpolygon.h>
1091 #include <QtGui/qregion.h>
1092 #include <QtGui/qbitmap.h>
1093 #include <QtGui/qcursor.h>
1094 #include <QtGui/qsizepolicy.h>
1095 #include <QtGui/qkeysequence.h>
1096 #include <QtGui/qpen.h>
1097 
1098 //#include <QtGui/qtextlength.h>
1099 #include <QtGui/qtextformat.h>
1100 #include <QtGui/qmatrix.h>
1101 #include <QtGui/qtransform.h>
1102 #include <QtGui/qmatrix4x4.h>
1103 #include <QtGui/qvector2d.h>
1104 #include <QtGui/qvector3d.h>
1105 #include <QtGui/qvector4d.h>
1106 #include <QtGui/qquaternion.h>
1107 
1109 
1111 
1113 {
1114  switch(type) {
1115  case QMetaType::VoidStar:
1118  case QMetaType::Long:
1119  case QMetaType::Int:
1120  case QMetaType::Short:
1121  case QMetaType::Char:
1122  case QMetaType::ULong:
1123  case QMetaType::UInt:
1124  case QMetaType::LongLong:
1125  case QMetaType::ULongLong:
1126  case QMetaType::UShort:
1127  case QMetaType::UChar:
1128  case QMetaType::Bool:
1129  case QMetaType::Float:
1130  case QMetaType::Double:
1131  case QMetaType::QChar:
1135  case QMetaType::QByteArray:
1136  case QMetaType::QString:
1138  case QMetaType::QBitArray:
1139  case QMetaType::QDate:
1140  case QMetaType::QTime:
1141  case QMetaType::QDateTime:
1142  case QMetaType::QUrl:
1143  case QMetaType::QLocale:
1144  case QMetaType::QRect:
1145  case QMetaType::QRectF:
1146  case QMetaType::QSize:
1147  case QMetaType::QSizeF:
1148  case QMetaType::QLine:
1149  case QMetaType::QLineF:
1150  case QMetaType::QPoint:
1151  case QMetaType::QPointF:
1152  case QMetaType::QVector3D:
1153 #ifndef QT_NO_REGEXP
1154  case QMetaType::QRegExp:
1155 #endif
1156  case QMetaType::Void:
1157 #ifdef QT3_SUPPORT
1158  case QMetaType::QColorGroup:
1159 #endif
1160  case QMetaType::QFont:
1161  case QMetaType::QPixmap:
1162  case QMetaType::QBrush:
1163  case QMetaType::QColor:
1164  case QMetaType::QPalette:
1165  case QMetaType::QIcon:
1166  case QMetaType::QImage:
1167  case QMetaType::QPolygon:
1168  case QMetaType::QRegion:
1169  case QMetaType::QBitmap:
1170 #ifndef QT_NO_CURSOR
1171  case QMetaType::QCursor:
1172 #endif
1175  case QMetaType::QPen:
1178  case QMetaType::QMatrix:
1179  case QMetaType::QTransform:
1180  case QMetaType::QMatrix4x4:
1181  case QMetaType::QVector2D:
1182  case QMetaType::QVector4D:
1184  return true;
1185 
1186  default:
1187  if (type == qMetaTypeId<QVariant>() ||
1188  type == qMetaTypeId<QScriptValue>() ||
1189  typeCategory(type) != Unknown) {
1190  return true;
1191  }
1192  break;
1193  }
1194 
1195  return false;
1196 }
1197 
1206 bool QDeclarativeMetaType::copy(int type, void *data, const void *copy)
1207 {
1208  if (copy) {
1209  switch(type) {
1210  case QMetaType::VoidStar:
1213  *static_cast<void **>(data) = *static_cast<void* const *>(copy);
1214  return true;
1215  case QMetaType::Long:
1216  *static_cast<long *>(data) = *static_cast<const long*>(copy);
1217  return true;
1218  case QMetaType::Int:
1219  *static_cast<int *>(data) = *static_cast<const int*>(copy);
1220  return true;
1221  case QMetaType::Short:
1222  *static_cast<short *>(data) = *static_cast<const short*>(copy);
1223  return true;
1224  case QMetaType::Char:
1225  *static_cast<char *>(data) = *static_cast<const char*>(copy);
1226  return true;
1227  case QMetaType::ULong:
1228  *static_cast<ulong *>(data) = *static_cast<const ulong*>(copy);
1229  return true;
1230  case QMetaType::UInt:
1231  *static_cast<uint *>(data) = *static_cast<const uint*>(copy);
1232  return true;
1233  case QMetaType::LongLong:
1234  *static_cast<qlonglong *>(data) = *static_cast<const qlonglong*>(copy);
1235  return true;
1236  case QMetaType::ULongLong:
1237  *static_cast<qulonglong *>(data) = *static_cast<const qulonglong*>(copy);
1238  return true;
1239  case QMetaType::UShort:
1240  *static_cast<ushort *>(data) = *static_cast<const ushort*>(copy);
1241  return true;
1242  case QMetaType::UChar:
1243  *static_cast<uchar *>(data) = *static_cast<const uchar*>(copy);
1244  return true;
1245  case QMetaType::Bool:
1246  *static_cast<bool *>(data) = *static_cast<const bool*>(copy);
1247  return true;
1248  case QMetaType::Float:
1249  *static_cast<float *>(data) = *static_cast<const float*>(copy);
1250  return true;
1251  case QMetaType::Double:
1252  *static_cast<double *>(data) = *static_cast<const double*>(copy);
1253  return true;
1254  case QMetaType::QChar:
1255  *static_cast<NS(QChar) *>(data) = *static_cast<const NS(QChar)*>(copy);
1256  return true;
1258  *static_cast<NS(QVariantMap) *>(data) = *static_cast<const NS(QVariantMap)*>(copy);
1259  return true;
1261  *static_cast<NS(QVariantHash) *>(data) = *static_cast<const NS(QVariantHash)*>(copy);
1262  return true;
1264  *static_cast<NS(QVariantList) *>(data) = *static_cast<const NS(QVariantList)*>(copy);
1265  return true;
1266  case QMetaType::QByteArray:
1267  *static_cast<NS(QByteArray) *>(data) = *static_cast<const NS(QByteArray)*>(copy);
1268  return true;
1269  case QMetaType::QString:
1270  *static_cast<NS(QString) *>(data) = *static_cast<const NS(QString)*>(copy);
1271  return true;
1273  *static_cast<NS(QStringList) *>(data) = *static_cast<const NS(QStringList)*>(copy);
1274  return true;
1275  case QMetaType::QBitArray:
1276  *static_cast<NS(QBitArray) *>(data) = *static_cast<const NS(QBitArray)*>(copy);
1277  return true;
1278  case QMetaType::QDate:
1279  *static_cast<NS(QDate) *>(data) = *static_cast<const NS(QDate)*>(copy);
1280  return true;
1281  case QMetaType::QTime:
1282  *static_cast<NS(QTime) *>(data) = *static_cast<const NS(QTime)*>(copy);
1283  return true;
1284  case QMetaType::QDateTime:
1285  *static_cast<NS(QDateTime) *>(data) = *static_cast<const NS(QDateTime)*>(copy);
1286  return true;
1287  case QMetaType::QUrl:
1288  *static_cast<NS(QUrl) *>(data) = *static_cast<const NS(QUrl)*>(copy);
1289  return true;
1290  case QMetaType::QLocale:
1291  *static_cast<NS(QLocale) *>(data) = *static_cast<const NS(QLocale)*>(copy);
1292  return true;
1293  case QMetaType::QRect:
1294  *static_cast<NS(QRect) *>(data) = *static_cast<const NS(QRect)*>(copy);
1295  return true;
1296  case QMetaType::QRectF:
1297  *static_cast<NS(QRectF) *>(data) = *static_cast<const NS(QRectF)*>(copy);
1298  return true;
1299  case QMetaType::QSize:
1300  *static_cast<NS(QSize) *>(data) = *static_cast<const NS(QSize)*>(copy);
1301  return true;
1302  case QMetaType::QSizeF:
1303  *static_cast<NS(QSizeF) *>(data) = *static_cast<const NS(QSizeF)*>(copy);
1304  return true;
1305  case QMetaType::QLine:
1306  *static_cast<NS(QLine) *>(data) = *static_cast<const NS(QLine)*>(copy);
1307  return true;
1308  case QMetaType::QLineF:
1309  *static_cast<NS(QLineF) *>(data) = *static_cast<const NS(QLineF)*>(copy);
1310  return true;
1311  case QMetaType::QPoint:
1312  *static_cast<NS(QPoint) *>(data) = *static_cast<const NS(QPoint)*>(copy);
1313  return true;
1314  case QMetaType::QPointF:
1315  *static_cast<NS(QPointF) *>(data) = *static_cast<const NS(QPointF)*>(copy);
1316  return true;
1317  case QMetaType::QVector3D:
1318  *static_cast<NS(QVector3D) *>(data) = *static_cast<const NS(QVector3D)*>(copy);
1319  return true;
1320 #ifndef QT_NO_REGEXP
1321  case QMetaType::QRegExp:
1322  *static_cast<NS(QRegExp) *>(data) = *static_cast<const NS(QRegExp)*>(copy);
1323  return true;
1324 #endif
1325  case QMetaType::Void:
1326  return true;
1327 
1328 
1329 #ifdef QT3_SUPPORT
1330  case QMetaType::QColorGroup:
1331  *static_cast<NS(QColorGroup) *>(data) = *static_cast<const NS(QColorGroup)*>(copy);
1332  return true;
1333 #endif
1334 
1335  case QMetaType::QFont:
1336  *static_cast<NS(QFont) *>(data) = *static_cast<const NS(QFont)*>(copy);
1337  return true;
1338  case QMetaType::QPixmap:
1339  *static_cast<NS(QPixmap) *>(data) = *static_cast<const NS(QPixmap)*>(copy);
1340  return true;
1341  case QMetaType::QBrush:
1342  *static_cast<NS(QBrush) *>(data) = *static_cast<const NS(QBrush)*>(copy);
1343  return true;
1344  case QMetaType::QColor:
1345  *static_cast<NS(QColor) *>(data) = *static_cast<const NS(QColor)*>(copy);
1346  return true;
1347  case QMetaType::QPalette:
1348  *static_cast<NS(QPalette) *>(data) = *static_cast<const NS(QPalette)*>(copy);
1349  return true;
1350  case QMetaType::QIcon:
1351  *static_cast<NS(QIcon) *>(data) = *static_cast<const NS(QIcon)*>(copy);
1352  return true;
1353  case QMetaType::QImage:
1354  *static_cast<NS(QImage) *>(data) = *static_cast<const NS(QImage)*>(copy);
1355  return true;
1356  case QMetaType::QPolygon:
1357  *static_cast<NS(QPolygon) *>(data) = *static_cast<const NS(QPolygon)*>(copy);
1358  return true;
1359  case QMetaType::QRegion:
1360  *static_cast<NS(QRegion) *>(data) = *static_cast<const NS(QRegion)*>(copy);
1361  return true;
1362  case QMetaType::QBitmap:
1363  *static_cast<NS(QBitmap) *>(data) = *static_cast<const NS(QBitmap)*>(copy);
1364  return true;
1365 #ifndef QT_NO_CURSOR
1366  case QMetaType::QCursor:
1367  *static_cast<NS(QCursor) *>(data) = *static_cast<const NS(QCursor)*>(copy);
1368  return true;
1369 #endif
1371  *static_cast<NS(QSizePolicy) *>(data) = *static_cast<const NS(QSizePolicy)*>(copy);
1372  return true;
1374  *static_cast<NS(QKeySequence) *>(data) = *static_cast<const NS(QKeySequence)*>(copy);
1375  return true;
1376  case QMetaType::QPen:
1377  *static_cast<NS(QPen) *>(data) = *static_cast<const NS(QPen)*>(copy);
1378  return true;
1380  *static_cast<NS(QTextLength) *>(data) = *static_cast<const NS(QTextLength)*>(copy);
1381  return true;
1383  *static_cast<NS(QTextFormat) *>(data) = *static_cast<const NS(QTextFormat)*>(copy);
1384  return true;
1385  case QMetaType::QMatrix:
1386  *static_cast<NS(QMatrix) *>(data) = *static_cast<const NS(QMatrix)*>(copy);
1387  return true;
1388  case QMetaType::QTransform:
1389  *static_cast<NS(QTransform) *>(data) = *static_cast<const NS(QTransform)*>(copy);
1390  return true;
1391  case QMetaType::QMatrix4x4:
1392  *static_cast<NS(QMatrix4x4) *>(data) = *static_cast<const NS(QMatrix4x4)*>(copy);
1393  return true;
1394  case QMetaType::QVector2D:
1395  *static_cast<NS(QVector2D) *>(data) = *static_cast<const NS(QVector2D)*>(copy);
1396  return true;
1397  case QMetaType::QVector4D:
1398  *static_cast<NS(QVector4D) *>(data) = *static_cast<const NS(QVector4D)*>(copy);
1399  return true;
1401  *static_cast<NS(QQuaternion) *>(data) = *static_cast<const NS(QQuaternion)*>(copy);
1402  return true;
1403 
1404  default:
1405  if (type == qMetaTypeId<QVariant>()) {
1406  *static_cast<NS(QVariant) *>(data) = *static_cast<const NS(QVariant)*>(copy);
1407  return true;
1408  } else if (type == qMetaTypeId<QScriptValue>()) {
1409  *static_cast<NS(QScriptValue) *>(data) = *static_cast<const NS(QScriptValue)*>(copy);
1410  return true;
1411  } else if (typeCategory(type) != Unknown) {
1412  *static_cast<void **>(data) = *static_cast<void* const *>(copy);
1413  return true;
1414  }
1415  break;
1416  }
1417  } else {
1418  switch(type) {
1419  case QMetaType::VoidStar:
1422  *static_cast<void **>(data) = 0;
1423  return true;
1424  case QMetaType::Long:
1425  *static_cast<long *>(data) = long(0);
1426  return true;
1427  case QMetaType::Int:
1428  *static_cast<int *>(data) = int(0);
1429  return true;
1430  case QMetaType::Short:
1431  *static_cast<short *>(data) = short(0);
1432  return true;
1433  case QMetaType::Char:
1434  *static_cast<char *>(data) = char(0);
1435  return true;
1436  case QMetaType::ULong:
1437  *static_cast<ulong *>(data) = ulong(0);
1438  return true;
1439  case QMetaType::UInt:
1440  *static_cast<uint *>(data) = uint(0);
1441  return true;
1442  case QMetaType::LongLong:
1443  *static_cast<qlonglong *>(data) = qlonglong(0);
1444  return true;
1445  case QMetaType::ULongLong:
1446  *static_cast<qulonglong *>(data) = qulonglong(0);
1447  return true;
1448  case QMetaType::UShort:
1449  *static_cast<ushort *>(data) = ushort(0);
1450  return true;
1451  case QMetaType::UChar:
1452  *static_cast<uchar *>(data) = uchar(0);
1453  return true;
1454  case QMetaType::Bool:
1455  *static_cast<bool *>(data) = bool(false);
1456  return true;
1457  case QMetaType::Float:
1458  *static_cast<float *>(data) = float(0);
1459  return true;
1460  case QMetaType::Double:
1461  *static_cast<double *>(data) = double(0);
1462  return true;
1463  case QMetaType::QChar:
1464  *static_cast<NS(QChar) *>(data) = NS(QChar)();
1465  return true;
1467  *static_cast<NS(QVariantMap) *>(data) = NS(QVariantMap)();
1468  return true;
1470  *static_cast<NS(QVariantHash) *>(data) = NS(QVariantHash)();
1471  return true;
1473  *static_cast<NS(QVariantList) *>(data) = NS(QVariantList)();
1474  return true;
1475  case QMetaType::QByteArray:
1476  *static_cast<NS(QByteArray) *>(data) = NS(QByteArray)();
1477  return true;
1478  case QMetaType::QString:
1479  *static_cast<NS(QString) *>(data) = NS(QString)();
1480  return true;
1482  *static_cast<NS(QStringList) *>(data) = NS(QStringList)();
1483  return true;
1484  case QMetaType::QBitArray:
1485  *static_cast<NS(QBitArray) *>(data) = NS(QBitArray)();
1486  return true;
1487  case QMetaType::QDate:
1488  *static_cast<NS(QDate) *>(data) = NS(QDate)();
1489  return true;
1490  case QMetaType::QTime:
1491  *static_cast<NS(QTime) *>(data) = NS(QTime)();
1492  return true;
1493  case QMetaType::QDateTime:
1494  *static_cast<NS(QDateTime) *>(data) = NS(QDateTime)();
1495  return true;
1496  case QMetaType::QUrl:
1497  *static_cast<NS(QUrl) *>(data) = NS(QUrl)();
1498  return true;
1499  case QMetaType::QLocale:
1500  *static_cast<NS(QLocale) *>(data) = NS(QLocale)();
1501  return true;
1502  case QMetaType::QRect:
1503  *static_cast<NS(QRect) *>(data) = NS(QRect)();
1504  return true;
1505  case QMetaType::QRectF:
1506  *static_cast<NS(QRectF) *>(data) = NS(QRectF)();
1507  return true;
1508  case QMetaType::QSize:
1509  *static_cast<NS(QSize) *>(data) = NS(QSize)();
1510  return true;
1511  case QMetaType::QSizeF:
1512  *static_cast<NS(QSizeF) *>(data) = NS(QSizeF)();
1513  return true;
1514  case QMetaType::QLine:
1515  *static_cast<NS(QLine) *>(data) = NS(QLine)();
1516  return true;
1517  case QMetaType::QLineF:
1518  *static_cast<NS(QLineF) *>(data) = NS(QLineF)();
1519  return true;
1520  case QMetaType::QPoint:
1521  *static_cast<NS(QPoint) *>(data) = NS(QPoint)();
1522  return true;
1523  case QMetaType::QPointF:
1524  *static_cast<NS(QPointF) *>(data) = NS(QPointF)();
1525  return true;
1526  case QMetaType::QVector3D:
1527  *static_cast<NS(QVector3D) *>(data) = NS(QVector3D)();
1528  return true;
1529 #ifndef QT_NO_REGEXP
1530  case QMetaType::QRegExp:
1531  *static_cast<NS(QRegExp) *>(data) = NS(QRegExp)();
1532  return true;
1533 #endif
1534  case QMetaType::Void:
1535  return true;
1536 
1537 #ifdef QT3_SUPPORT
1538  case QMetaType::QColorGroup:
1539  *static_cast<NS(QColorGroup) *>(data) = NS(QColorGroup)();
1540  return true;
1541 #endif
1542 
1543  case QMetaType::QFont:
1544  *static_cast<NS(QFont) *>(data) = NS(QFont)();
1545  return true;
1546  case QMetaType::QPixmap:
1547  *static_cast<NS(QPixmap) *>(data) = NS(QPixmap)();
1548  return true;
1549  case QMetaType::QBrush:
1550  *static_cast<NS(QBrush) *>(data) = NS(QBrush)();
1551  return true;
1552  case QMetaType::QColor:
1553  *static_cast<NS(QColor) *>(data) = NS(QColor)();
1554  return true;
1555  case QMetaType::QPalette:
1556  *static_cast<NS(QPalette) *>(data) = NS(QPalette)();
1557  return true;
1558  case QMetaType::QIcon:
1559  *static_cast<NS(QIcon) *>(data) = NS(QIcon)();
1560  return true;
1561  case QMetaType::QImage:
1562  *static_cast<NS(QImage) *>(data) = NS(QImage)();
1563  return true;
1564  case QMetaType::QPolygon:
1565  *static_cast<NS(QPolygon) *>(data) = NS(QPolygon)();
1566  return true;
1567  case QMetaType::QRegion:
1568  *static_cast<NS(QRegion) *>(data) = NS(QRegion)();
1569  return true;
1570  case QMetaType::QBitmap:
1571  *static_cast<NS(QBitmap) *>(data) = NS(QBitmap)();
1572  return true;
1573 #ifndef QT_NO_CURSOR
1574  case QMetaType::QCursor:
1575  *static_cast<NS(QCursor) *>(data) = NS(QCursor)();
1576  return true;
1577 #endif
1579  *static_cast<NS(QSizePolicy) *>(data) = NS(QSizePolicy)();
1580  return true;
1582  *static_cast<NS(QKeySequence) *>(data) = NS(QKeySequence)();
1583  return true;
1584  case QMetaType::QPen:
1585  *static_cast<NS(QPen) *>(data) = NS(QPen)();
1586  return true;
1588  *static_cast<NS(QTextLength) *>(data) = NS(QTextLength)();
1589  return true;
1591  *static_cast<NS(QTextFormat) *>(data) = NS(QTextFormat)();
1592  return true;
1593  case QMetaType::QMatrix:
1594  *static_cast<NS(QMatrix) *>(data) = NS(QMatrix)();
1595  return true;
1596  case QMetaType::QTransform:
1597  *static_cast<NS(QTransform) *>(data) = NS(QTransform)();
1598  return true;
1599  case QMetaType::QMatrix4x4:
1600  *static_cast<NS(QMatrix4x4) *>(data) = NS(QMatrix4x4)();
1601  return true;
1602  case QMetaType::QVector2D:
1603  *static_cast<NS(QVector2D) *>(data) = NS(QVector2D)();
1604  return true;
1605  case QMetaType::QVector4D:
1606  *static_cast<NS(QVector4D) *>(data) = NS(QVector4D)();
1607  return true;
1609  *static_cast<NS(QQuaternion) *>(data) = NS(QQuaternion)();
1610  return true;
1611  default:
1612  if (type == qMetaTypeId<QVariant>()) {
1613  *static_cast<NS(QVariant) *>(data) = NS(QVariant)();
1614  return true;
1615  } else if (type == qMetaTypeId<QScriptValue>()) {
1616  *static_cast<NS(QScriptValue) *>(data) = NS(QScriptValue)();
1617  return true;
1618  } else if (typeCategory(type) != Unknown) {
1619  *static_cast<void **>(data) = 0;
1620  return true;
1621  }
1622  break;
1623  }
1624  }
1625 
1626  return false;
1627 }
1628 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static QObject * toQObject(const QVariant &, bool *ok=0)
CreateFunc createFunction() const
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
QObject *(* QDeclarativeAttachedPropertiesFunc)(QObject *)
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
static const char * interfaceIId(int)
static bool isModule(const QByteArray &module, int versionMajor, int versionMinor)
const QMetaObject * m_baseMetaObject
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvector3d.h:60
static void registerCustomStringConverter(int, StringConverter)
A custom string convertor allows you to specify a function pointer that returns a variant of type...
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
int type
Definition: qmetatype.cpp:239
QByteArray module() const
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
static mach_timebase_info_data_t info
unsigned char c[8]
Definition: qnumeric_p.h:62
The QMetaEnum class provides meta-data about an enumerator.
Definition: qmetaobject.h:147
void setBit(int i)
Sets the bit at index position i to 1.
Definition: qbitarray.h:128
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int propertyValueInterceptorCast() const
QDeclarativeAttachedPropertiesFunc m_attachedPropertiesFunc
static QDeclarativeAttachedPropertiesFunc attachedPropertiesFuncById(int)
QDeclarativeCustomParser * customParser
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:57
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
void(* CreateFunc)(void *)
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
#define it(className, varName)
QHash< QByteArray, QDeclarativeType * > Names
const QMetaObject * m_attachedPropertiesType
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
ModuleInfo(int major_min, int minor_min, int major_max, int minor_max)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static bool canCopy(int type)
The QVector4D class represents a vector or vertex in 4D space.
Definition: qvector4d.h:60
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static QList< QDeclarativeType * > qmlTypes()
Returns the list of registered QML types.
static bool copy(int type, void *data, const void *copy=0)
Copies copy into data, assuming they both are of type type.
QDeclarativeTypePrivate * d
void setAccess(QMetaMethod::Access value)
Sets the access specification of this method (private, protected, or public) to value.
static QDeclarativeType * qmlType(const QByteArray &, int, int)
Returns the type (if any) of URI-qualified named name in version specified by version_major and versi...
friend int registerComponent(const QDeclarativePrivate::RegisterComponent &)
static int attachedPropertiesFuncId(const QMetaObject *)
The QDate class provides date functions.
Definition: qdatetime.h:55
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QMetaObject * baseMetaObject() const
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
int attachedPropertiesId() const
The QPolygon class provides a vector of points using integer precision.
Definition: qpolygon.h:60
QDeclarativeType * superType() const
void unlock()
Unlocks the lock associated with this locker.
static QHash< const QMetaObject *, int > m_attachedPropertyIds
int propertyCount() const
Returns the number of properties in this class, including the number of properties provided by each b...
QList< QDeclarativeDirParser::Component > QDeclarativeDirComponents
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
static QString currentPath()
Returns the absolute path of the application&#39;s current directory.
Definition: qdir.cpp:1875
bool testBit(int i) const
Returns true if the bit at index position i is 1; otherwise returns false.
Definition: qbitarray.h:124
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
const char * value() const
Returns the value of this item.
QList< QDeclarativePrivate::AutoParentFunction > parentFunctions
The QMetaMethodBuilder class enables modifications to a method definition on a meta object builder...
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
int indexOfProperty(const char *name) const
Finds property name and returns its index; otherwise returns -1.
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
const char * name() const
Returns the name of the enumerator (without the scope).
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
Definition: qurl.cpp:5880
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
bool containsRevisionedAttributes() const
QMap< QByteArray, QDeclarativeDirComponents * > registeredComponents
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
const char * interfaceIId() const
static TypeCategory typeCategory(int)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
static QList< QByteArray > qmlTypeNames()
Returns the list of registered QML type names.
const Key & key() const
Returns the current item&#39;s key.
Definition: qhash.h:419
QHash< int, QDeclarativeMetaType::StringConverter > StringConverters
#define NS(x)
unsigned char uchar
Definition: qglobal.h:994
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QTime class provides clock time functions.
Definition: qdatetime.h:148
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QHash< int, QDeclarativeType * > Ids
QByteArray typeName() const
static QDeclarativeDirComponents qmlComponents(const QByteArray &module, int version_major, int version_minor)
Returns the component(s) that have been registered for the module specified by uri and the version sp...
QDeclarativeCustomParser * m_customParser
The QTextFormat class provides formatting information for a QTextDocument.
Definition: qtextformat.h:129
QMetaPropertyBuilder addProperty(const QByteArray &name, const QByteArray &type, int notifierId=-1)
Adds a new readable/writable property to this class with the specified name and type.
static bool init
friend int registerInterface(const QDeclarativePrivate::RegisterInterface &)
const char * name
QDeclarativeType(int, const QDeclarativePrivate::RegisterInterface &)
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
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
QHash< const QMetaObject *, QDeclarativeType * > MetaObjects
QList< QDeclarativeType * > types
int propertyValueSourceCast() const
QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction() const
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
void resize(int size)
Resizes the bit array to size bits.
Definition: qbitarray.cpp:214
Q_CORE_EXPORT void qWarning(const char *,...)
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition: qmatrix4x4.h:63
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QVector2D class represents a vector or vertex in 2D space.
Definition: qvector2d.h:60
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
QByteArray qmlTypeName() const
static QList< QDeclarativePrivate::AutoParentFunction > parentFunctions()
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
const char * name() const
Returns the name of this item.
QString noCreationReason() const
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
int Q_DECLARATIVE_EXPORT qmlregister(RegistrationType, void *)
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
The QReadLocker class is a convenience class that simplifies locking and unlocking read-write locks f...
unsigned long ulong
Definition: qglobal.h:997
int classInfoCount() const
Returns the number of items of class information in this class.
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
The QDeclarativeCustomParser class allows you to add new arbitrary types to QML.
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
QObject *(* m_extFunc)(QObject *)
The QWriteLocker class is a convenience class that simplifies locking and unlocking read-write locks ...
The QBitArray class provides an array of bits.
Definition: qbitarray.h:54
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
int registerAutoParentFunction(QDeclarativePrivate::RegisterAutoParent &autoparent)
Q_CORE_EXPORT void qFatal(const char *,...)
const QMetaObject * metaObject() const
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
const QMetaObject * attachedPropertiesType() const
QHash< QByteArray, ModuleInfo > ModuleInfoHash
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
static const struct @32 types[]
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
The QMetaClassInfo class provides additional information about a class.
Definition: qmetaobject.h:224
const QMetaObject * m_extMetaObject
unsigned short ushort
Definition: qglobal.h:995
const QMetaObject * attachedPropertiesMetaObject
The QReadWriteLock class provides read-write locking.
QObject *(* extensionObjectCreate)(QObject *)
int indexOfMethod(const char *method) const
Finds method and returns its index; otherwise returns -1.
QDeclarativeAttachedPropertiesFunc attachedPropertiesFunction
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
Definition: qhash.h:693
const void * constData() const
Definition: qvariant.cpp:3065
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int classInfoOffset() const
Returns the class information offset for this class; i.e.
const QMetaObject * superdata
Definition: qobjectdefs.h:469
The QTextLength class encapsulates the different types of length used in a QTextDocument.
Definition: qtextformat.h:84
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QList< QDeclarativeProxyMetaObject::ProxyData > m_metaObjects
Q_DECLARE_METATYPE(QScriptValue)
const char * property
Definition: qwizard.cpp:138
static QReadWriteLock lock
Definition: proxyconf.cpp:399
struct QMetaObject::@38 d
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QColorGroup class contains color groups for each widget state.
static StringConverter customStringConverter(int)
Return the custom string converter for type, previously installed through registerCustomStringConvert...
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59
QDeclarativeCustomParser * customParser() const
quint16 index
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QObject * create() const
int revision() const
Returns the method revision if one was specified by Q_REVISION, otherwise returns 0...
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition: qurl.cpp:6374
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
int addClassInfo(const QByteArray &name, const QByteArray &value)
Adds name and value as an item of class information to this class.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
quint64 qulonglong
Definition: qglobal.h:952
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)).
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
int revision() const
Returns the property revision if one was specified by REVISION, otherwise returns 0...
iterator insertMulti(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:772
QMetaObject * toMetaObject() const
Converts this meta object builder into a concrete QMetaObject.
void unlock()
Unlocks the lock associated with this locker.
qint64 qlonglong
Definition: qglobal.h:951
friend int registerType(const QDeclarativePrivate::RegisterType &)
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
int size() const
Returns the number of bits stored in the bit array.
Definition: qbitarray.h:73
static QMetaMethod defaultMethod(const QMetaObject *)
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
Definition: qhash.h:648
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
bool availableInVersion(int vmajor, int vminor) const
iterator Iterator
Qt-style synonym for QHash::iterator.
Definition: qhash.h:473
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
QVariant(* StringConverter)(const QString &)
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo, const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd)
static QMetaProperty defaultProperty(const QMetaObject *)
#define Q_FUNC_INFO
Definition: qglobal.h:1871
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480