| 1 |
/* |
| 2 |
* This file is part of the API Extractor project. |
| 3 |
* |
| 4 |
* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 5 |
* |
| 6 |
* Contact: PySide team <contact@pyside.org> |
| 7 |
* |
| 8 |
* This program is free software; you can redistribute it and/or |
| 9 |
* modify it under the terms of the GNU General Public License |
| 10 |
* version 2 as published by the Free Software Foundation. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, but |
| 13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
* General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this program; if not, write to the Free Software |
| 19 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 |
* 02110-1301 USA |
| 21 |
* |
| 22 |
*/ |
| 23 |
|
| 24 |
#ifndef ABSTRACTMETALANG_H |
| 25 |
#define ABSTRACTMETALANG_H |
| 26 |
|
| 27 |
#include "typesystem.h" |
| 28 |
|
| 29 |
#include <QtCore/QSet> |
| 30 |
#include <QtCore/QStringList> |
| 31 |
#include <QtCore/QTextStream> |
| 32 |
#include <QSharedPointer> |
| 33 |
|
| 34 |
|
| 35 |
class AbstractMeta; |
| 36 |
class AbstractMetaClass; |
| 37 |
class AbstractMetaField; |
| 38 |
class AbstractMetaFunction; |
| 39 |
class AbstractMetaType; |
| 40 |
class AbstractMetaVariable; |
| 41 |
class AbstractMetaArgument; |
| 42 |
class AbstractMetaEnumValue; |
| 43 |
class AbstractMetaEnum; |
| 44 |
class QPropertySpec; |
| 45 |
|
| 46 |
class APIEXTRACTOR_API Documentation |
| 47 |
{ |
| 48 |
public: |
| 49 |
enum Format { |
| 50 |
Native, |
| 51 |
Target |
| 52 |
}; |
| 53 |
|
| 54 |
Documentation() |
| 55 |
: m_format(Documentation::Native) {} |
| 56 |
|
| 57 |
Documentation(const QString& value, Format fmt = Documentation::Native) |
| 58 |
: m_data(value), m_format(fmt) {} |
| 59 |
|
| 60 |
QString value() const |
| 61 |
{ |
| 62 |
return m_data; |
| 63 |
} |
| 64 |
|
| 65 |
void setValue(const QString& value, Format fmt = Documentation::Native) |
| 66 |
{ |
| 67 |
m_data = value; m_format = fmt; |
| 68 |
} |
| 69 |
|
| 70 |
Documentation::Format format() const |
| 71 |
{ |
| 72 |
return m_format; |
| 73 |
} |
| 74 |
|
| 75 |
private: |
| 76 |
QString m_data; |
| 77 |
Format m_format; |
| 78 |
|
| 79 |
}; |
| 80 |
|
| 81 |
typedef QList<AbstractMetaField *> AbstractMetaFieldList; |
| 82 |
typedef QList<AbstractMetaArgument *> AbstractMetaArgumentList; |
| 83 |
typedef QList<AbstractMetaFunction *> AbstractMetaFunctionList; |
| 84 |
class APIEXTRACTOR_API AbstractMetaClassList : public QList<AbstractMetaClass *> |
| 85 |
{ |
| 86 |
public: |
| 87 |
AbstractMetaClass *findClass(const QString &name) const; |
| 88 |
AbstractMetaClass *findClass(const TypeEntry* typeEntry) const; |
| 89 |
AbstractMetaEnumValue *findEnumValue(const QString &string) const; |
| 90 |
AbstractMetaEnum *findEnum(const EnumTypeEntry *entry) const; |
| 91 |
|
| 92 |
}; |
| 93 |
|
| 94 |
class APIEXTRACTOR_API AbstractMetaAttributes |
| 95 |
{ |
| 96 |
public: |
| 97 |
AbstractMetaAttributes() : m_attributes(0), m_originalAttributes(0) {}; |
| 98 |
|
| 99 |
enum Attribute { |
| 100 |
None = 0x00000000, |
| 101 |
|
| 102 |
Private = 0x00000001, |
| 103 |
Protected = 0x00000002, |
| 104 |
Public = 0x00000004, |
| 105 |
Friendly = 0x00000008, |
| 106 |
Visibility = 0x0000000f, |
| 107 |
|
| 108 |
Native = 0x00000010, |
| 109 |
Abstract = 0x00000020, |
| 110 |
Static = 0x00000040, |
| 111 |
|
| 112 |
FinalInTargetLang = 0x00000080, |
| 113 |
FinalInCpp = 0x00000100, |
| 114 |
ForceShellImplementation = 0x00000200, |
| 115 |
|
| 116 |
GetterFunction = 0x00000400, |
| 117 |
SetterFunction = 0x00000800, |
| 118 |
|
| 119 |
FinalOverload = 0x00001000, |
| 120 |
InterfaceFunction = 0x00002000, |
| 121 |
|
| 122 |
PropertyReader = 0x00004000, |
| 123 |
PropertyWriter = 0x00008000, |
| 124 |
PropertyResetter = 0x00010000, |
| 125 |
|
| 126 |
Fake = 0x00020000, |
| 127 |
|
| 128 |
Invokable = 0x00040000, |
| 129 |
|
| 130 |
Final = FinalInTargetLang | FinalInCpp |
| 131 |
}; |
| 132 |
|
| 133 |
uint attributes() const |
| 134 |
{ |
| 135 |
return m_attributes; |
| 136 |
} |
| 137 |
|
| 138 |
void setAttributes(uint attributes) |
| 139 |
{ |
| 140 |
m_attributes = attributes; |
| 141 |
} |
| 142 |
|
| 143 |
uint originalAttributes() const |
| 144 |
{ |
| 145 |
return m_originalAttributes; |
| 146 |
} |
| 147 |
|
| 148 |
void setOriginalAttributes(uint attributes) |
| 149 |
{ |
| 150 |
m_originalAttributes = attributes; |
| 151 |
} |
| 152 |
|
| 153 |
uint visibility() const |
| 154 |
{ |
| 155 |
return m_attributes & Visibility; |
| 156 |
} |
| 157 |
|
| 158 |
void setVisibility(uint visi) |
| 159 |
{ |
| 160 |
m_attributes = (m_attributes & ~Visibility) | visi; |
| 161 |
} |
| 162 |
|
| 163 |
void operator+=(Attribute attribute) |
| 164 |
{ |
| 165 |
m_attributes |= attribute; |
| 166 |
} |
| 167 |
|
| 168 |
void operator-=(Attribute attribute) |
| 169 |
{ |
| 170 |
m_attributes &= ~attribute; |
| 171 |
} |
| 172 |
|
| 173 |
bool isNative() const |
| 174 |
{ |
| 175 |
return m_attributes & Native; |
| 176 |
} |
| 177 |
|
| 178 |
bool isFinal() const |
| 179 |
{ |
| 180 |
return (m_attributes & Final) == Final; |
| 181 |
} |
| 182 |
|
| 183 |
bool isFinalInTargetLang() const |
| 184 |
{ |
| 185 |
return m_attributes & FinalInTargetLang; |
| 186 |
} |
| 187 |
|
| 188 |
bool isFinalInCpp() const |
| 189 |
{ |
| 190 |
return m_attributes & FinalInCpp; |
| 191 |
} |
| 192 |
|
| 193 |
bool isAbstract() const |
| 194 |
{ |
| 195 |
return m_attributes & Abstract; |
| 196 |
} |
| 197 |
|
| 198 |
bool isStatic() const |
| 199 |
{ |
| 200 |
return m_attributes & Static; |
| 201 |
} |
| 202 |
|
| 203 |
bool isForcedShellImplementation() const |
| 204 |
{ |
| 205 |
return m_attributes & ForceShellImplementation; |
| 206 |
} |
| 207 |
|
| 208 |
bool isInterfaceFunction() const |
| 209 |
{ |
| 210 |
return m_attributes & InterfaceFunction; |
| 211 |
} |
| 212 |
|
| 213 |
bool isFinalOverload() const |
| 214 |
{ |
| 215 |
return m_attributes & FinalOverload; |
| 216 |
} |
| 217 |
|
| 218 |
bool isInvokable() const |
| 219 |
{ |
| 220 |
return m_attributes & Invokable; |
| 221 |
} |
| 222 |
|
| 223 |
bool isPropertyReader() const |
| 224 |
{ |
| 225 |
return m_attributes & PropertyReader; |
| 226 |
} |
| 227 |
|
| 228 |
bool isPropertyWriter() const |
| 229 |
{ |
| 230 |
return m_attributes & PropertyWriter; |
| 231 |
} |
| 232 |
|
| 233 |
bool isPropertyResetter() const |
| 234 |
{ |
| 235 |
return m_attributes & PropertyResetter; |
| 236 |
} |
| 237 |
|
| 238 |
bool isPrivate() const |
| 239 |
{ |
| 240 |
return m_attributes & Private; |
| 241 |
} |
| 242 |
|
| 243 |
bool isProtected() const |
| 244 |
{ |
| 245 |
return m_attributes & Protected; |
| 246 |
} |
| 247 |
|
| 248 |
bool isPublic() const |
| 249 |
{ |
| 250 |
return m_attributes & Public; |
| 251 |
} |
| 252 |
|
| 253 |
bool isFriendly() const |
| 254 |
{ |
| 255 |
return m_attributes & Friendly; |
| 256 |
} |
| 257 |
|
| 258 |
bool wasPrivate() const |
| 259 |
{ |
| 260 |
return m_originalAttributes & Private; |
| 261 |
} |
| 262 |
|
| 263 |
bool wasProtected() const |
| 264 |
{ |
| 265 |
return m_originalAttributes & Protected; |
| 266 |
} |
| 267 |
|
| 268 |
bool wasPublic() const |
| 269 |
{ |
| 270 |
return m_originalAttributes & Public; |
| 271 |
} |
| 272 |
|
| 273 |
bool wasFriendly() const |
| 274 |
{ |
| 275 |
return m_originalAttributes & Friendly; |
| 276 |
} |
| 277 |
|
| 278 |
void setDocumentation(const Documentation& doc) |
| 279 |
{ |
| 280 |
m_doc = doc; |
| 281 |
} |
| 282 |
|
| 283 |
Documentation documentation() const |
| 284 |
{ |
| 285 |
return m_doc; |
| 286 |
} |
| 287 |
|
| 288 |
private: |
| 289 |
uint m_attributes; |
| 290 |
uint m_originalAttributes; |
| 291 |
Documentation m_doc; |
| 292 |
}; |
| 293 |
|
| 294 |
typedef QList<AbstractMetaType*> AbstractMetaTypeList; |
| 295 |
class APIEXTRACTOR_API AbstractMetaType |
| 296 |
{ |
| 297 |
public: |
| 298 |
|
| 299 |
enum TypeUsagePattern { |
| 300 |
InvalidPattern, |
| 301 |
PrimitivePattern, |
| 302 |
FlagsPattern, |
| 303 |
EnumPattern, |
| 304 |
ValuePattern, |
| 305 |
StringPattern, |
| 306 |
CharPattern, |
| 307 |
ObjectPattern, |
| 308 |
QObjectPattern, |
| 309 |
ValuePointerPattern, |
| 310 |
NativePointerPattern, |
| 311 |
ContainerPattern, |
| 312 |
VariantPattern, |
| 313 |
VarargsPattern, |
| 314 |
JObjectWrapperPattern, |
| 315 |
ArrayPattern, |
| 316 |
ThreadPattern |
| 317 |
}; |
| 318 |
|
| 319 |
AbstractMetaType(); |
| 320 |
~AbstractMetaType(); |
| 321 |
|
| 322 |
QString package() const |
| 323 |
{ |
| 324 |
return m_typeEntry->targetLangPackage(); |
| 325 |
} |
| 326 |
QString name() const |
| 327 |
{ |
| 328 |
if (m_name.isNull()) |
| 329 |
m_name = m_typeEntry->targetLangName().split("::").last(); |
| 330 |
return m_name; |
| 331 |
} |
| 332 |
QString fullName() const |
| 333 |
{ |
| 334 |
return m_typeEntry->qualifiedTargetLangName(); |
| 335 |
} |
| 336 |
|
| 337 |
void setTypeUsagePattern(TypeUsagePattern pattern) |
| 338 |
{ |
| 339 |
m_pattern = pattern; |
| 340 |
} |
| 341 |
TypeUsagePattern typeUsagePattern() const |
| 342 |
{ |
| 343 |
return m_pattern; |
| 344 |
} |
| 345 |
|
| 346 |
// true when use pattern is container |
| 347 |
bool hasInstantiations() const |
| 348 |
{ |
| 349 |
return !m_instantiations.isEmpty(); |
| 350 |
} |
| 351 |
|
| 352 |
void addInstantiation(AbstractMetaType* inst, bool owner = false) |
| 353 |
{ |
| 354 |
if (owner) |
| 355 |
m_children << inst; |
| 356 |
m_instantiations << inst; |
| 357 |
} |
| 358 |
|
| 359 |
void setInstantiations(const AbstractMetaTypeList &insts, bool owner = false) |
| 360 |
{ |
| 361 |
m_instantiations = insts; |
| 362 |
if (owner) { |
| 363 |
m_children.clear(); |
| 364 |
m_children = insts; |
| 365 |
} |
| 366 |
} |
| 367 |
|
| 368 |
AbstractMetaTypeList instantiations() const |
| 369 |
{ |
| 370 |
return m_instantiations; |
| 371 |
} |
| 372 |
|
| 373 |
void setInstantiationInCpp(bool incpp) |
| 374 |
{ |
| 375 |
m_cppInstantiation = incpp; |
| 376 |
} |
| 377 |
bool hasInstantiationInCpp() const |
| 378 |
{ |
| 379 |
return hasInstantiations() && m_cppInstantiation; |
| 380 |
} |
| 381 |
|
| 382 |
QString minimalSignature() const; |
| 383 |
|
| 384 |
// true when the type is a QtJambiObject subclass |
| 385 |
bool hasNativeId() const; |
| 386 |
|
| 387 |
// returns true if the typs is used as a non complex primitive, no & or *'s |
| 388 |
bool isPrimitive() const |
| 389 |
{ |
| 390 |
return m_pattern == PrimitivePattern; |
| 391 |
} |
| 392 |
|
| 393 |
// returns true if the type is used as an enum |
| 394 |
bool isEnum() const |
| 395 |
{ |
| 396 |
return m_pattern == EnumPattern; |
| 397 |
} |
| 398 |
|
| 399 |
// returns true if the type is used as a QObject * |
| 400 |
bool isQObject() const |
| 401 |
{ |
| 402 |
return m_pattern == QObjectPattern; |
| 403 |
} |
| 404 |
|
| 405 |
// returns true if the type is used as an object, e.g. Xxx * |
| 406 |
bool isObject() const |
| 407 |
{ |
| 408 |
return m_pattern == ObjectPattern; |
| 409 |
} |
| 410 |
|
| 411 |
// returns true if the type is used as an array, e.g. Xxx[42] |
| 412 |
bool isArray() const |
| 413 |
{ |
| 414 |
return m_pattern == ArrayPattern; |
| 415 |
} |
| 416 |
|
| 417 |
// returns true if the type is used as a value type (X or const X &) |
| 418 |
bool isValue() const |
| 419 |
{ |
| 420 |
return m_pattern == ValuePattern; |
| 421 |
} |
| 422 |
|
| 423 |
bool isValuePointer() const |
| 424 |
{ |
| 425 |
return m_pattern == ValuePointerPattern; |
| 426 |
} |
| 427 |
|
| 428 |
// returns true for more complex types... |
| 429 |
bool isNativePointer() const |
| 430 |
{ |
| 431 |
return m_pattern == NativePointerPattern; |
| 432 |
} |
| 433 |
|
| 434 |
// returns true if the type was originally a QString or const QString & or equivalent for QLatin1String |
| 435 |
bool isTargetLangString() const |
| 436 |
{ |
| 437 |
return m_pattern == StringPattern; |
| 438 |
} |
| 439 |
|
| 440 |
// returns true if the type was originally a QChar or const QChar & |
| 441 |
bool isTargetLangChar() const |
| 442 |
{ |
| 443 |
return m_pattern == CharPattern; |
| 444 |
} |
| 445 |
|
| 446 |
// return true if the type was originally a QVariant or const QVariant & |
| 447 |
bool isVariant() const |
| 448 |
{ |
| 449 |
return m_pattern == VariantPattern; |
| 450 |
} |
| 451 |
|
| 452 |
// return true if the type was originally a varargs |
| 453 |
bool isVarargs() const |
| 454 |
{ |
| 455 |
return m_pattern == VarargsPattern; |
| 456 |
} |
| 457 |
|
| 458 |
// return true if the type was originally a JObjectWrapper or const JObjectWrapper & |
| 459 |
bool isJObjectWrapper() const |
| 460 |
{ |
| 461 |
return m_pattern == JObjectWrapperPattern; |
| 462 |
} |
| 463 |
|
| 464 |
// returns true if the type was used as a container |
| 465 |
bool isContainer() const |
| 466 |
{ |
| 467 |
return m_pattern == ContainerPattern; |
| 468 |
} |
| 469 |
|
| 470 |
// returns true if the type was used as a flag |
| 471 |
bool isFlags() const |
| 472 |
{ |
| 473 |
return m_pattern == FlagsPattern; |
| 474 |
} |
| 475 |
|
| 476 |
// returns true if the type was used as a thread |
| 477 |
bool isThread() const |
| 478 |
{ |
| 479 |
return m_pattern == ThreadPattern; |
| 480 |
} |
| 481 |
|
| 482 |
bool isConstant() const |
| 483 |
{ |
| 484 |
return m_constant; |
| 485 |
} |
| 486 |
void setConstant(bool constant) |
| 487 |
{ |
| 488 |
m_constant = constant; |
| 489 |
} |
| 490 |
|
| 491 |
bool isReference() const |
| 492 |
{ |
| 493 |
return m_reference; |
| 494 |
} |
| 495 |
void setReference(bool ref) |
| 496 |
{ |
| 497 |
m_reference = ref; |
| 498 |
} |
| 499 |
|
| 500 |
/** |
| 501 |
* Says if the type is to be implemented using target language |
| 502 |
* equivalent of C++ enums, i.e. not plain ints. |
| 503 |
* /return true if the type is to be implemented using target |
| 504 |
* language enums |
| 505 |
*/ |
| 506 |
bool isTargetLangEnum() const |
| 507 |
{ |
| 508 |
return isEnum() && !((EnumTypeEntry *) typeEntry())->forceInteger(); |
| 509 |
} |
| 510 |
bool isIntegerEnum() const |
| 511 |
{ |
| 512 |
return isEnum() && !isTargetLangEnum(); |
| 513 |
} |
| 514 |
|
| 515 |
/** |
| 516 |
* Says if the type is to be implemented using target language |
| 517 |
* equivalent of Qt's QFlags, i.e. not plain ints. |
| 518 |
* /return true if the type is to be implemented using target |
| 519 |
* language QFlags |
| 520 |
*/ |
| 521 |
bool isTargetLangFlags() const |
| 522 |
{ |
| 523 |
return isFlags() && !((FlagsTypeEntry *) typeEntry())->forceInteger(); |
| 524 |
} |
| 525 |
bool isIntegerFlags() const |
| 526 |
{ |
| 527 |
return isFlags() && !isTargetLangFlags(); |
| 528 |
} |
| 529 |
|
| 530 |
int actualIndirections() const |
| 531 |
{ |
| 532 |
return m_indirections + (isReference() ? 1 : 0); |
| 533 |
} |
| 534 |
int indirections() const |
| 535 |
{ |
| 536 |
return m_indirections; |
| 537 |
} |
| 538 |
void setIndirections(int indirections) |
| 539 |
{ |
| 540 |
m_indirections = indirections; |
| 541 |
} |
| 542 |
|
| 543 |
void setArrayElementCount(int n) |
| 544 |
{ |
| 545 |
m_arrayElementCount = n; |
| 546 |
} |
| 547 |
int arrayElementCount() const |
| 548 |
{ |
| 549 |
return m_arrayElementCount; |
| 550 |
} |
| 551 |
|
| 552 |
const AbstractMetaType *arrayElementType() const |
| 553 |
{ |
| 554 |
return m_arrayElementType; |
| 555 |
} |
| 556 |
void setArrayElementType(const AbstractMetaType *t) |
| 557 |
{ |
| 558 |
m_arrayElementType = t; |
| 559 |
} |
| 560 |
|
| 561 |
QString cppSignature() const; |
| 562 |
|
| 563 |
AbstractMetaType *copy() const; |
| 564 |
|
| 565 |
const TypeEntry *typeEntry() const |
| 566 |
{ |
| 567 |
return m_typeEntry; |
| 568 |
} |
| 569 |
void setTypeEntry(const TypeEntry *type) |
| 570 |
{ |
| 571 |
m_typeEntry = type; |
| 572 |
} |
| 573 |
|
| 574 |
void setOriginalTypeDescription(const QString &otd) |
| 575 |
{ |
| 576 |
m_originalTypeDescription = otd; |
| 577 |
} |
| 578 |
QString originalTypeDescription() const |
| 579 |
{ |
| 580 |
return m_originalTypeDescription; |
| 581 |
} |
| 582 |
|
| 583 |
void setOriginalTemplateType(const AbstractMetaType *type) |
| 584 |
{ |
| 585 |
m_originalTemplateType = type; |
| 586 |
} |
| 587 |
const AbstractMetaType *originalTemplateType() const |
| 588 |
{ |
| 589 |
return m_originalTemplateType; |
| 590 |
} |
| 591 |
|
| 592 |
/// Decides and sets the proper usage patter for the current meta type. |
| 593 |
void decideUsagePattern(); |
| 594 |
|
| 595 |
private: |
| 596 |
const TypeEntry *m_typeEntry; |
| 597 |
AbstractMetaTypeList m_instantiations; |
| 598 |
QString m_package; |
| 599 |
mutable QString m_name; |
| 600 |
mutable QString m_cachedCppSignature; |
| 601 |
QString m_originalTypeDescription; |
| 602 |
|
| 603 |
int m_arrayElementCount; |
| 604 |
const AbstractMetaType *m_arrayElementType; |
| 605 |
const AbstractMetaType *m_originalTemplateType; |
| 606 |
|
| 607 |
TypeUsagePattern m_pattern; |
| 608 |
uint m_constant : 1; |
| 609 |
uint m_reference : 1; |
| 610 |
uint m_cppInstantiation : 1; |
| 611 |
int m_indirections : 4; |
| 612 |
uint m_reserved : 25; // unused |
| 613 |
AbstractMetaTypeList m_children; |
| 614 |
|
| 615 |
Q_DISABLE_COPY(AbstractMetaType); |
| 616 |
}; |
| 617 |
|
| 618 |
class APIEXTRACTOR_API AbstractMetaVariable |
| 619 |
{ |
| 620 |
public: |
| 621 |
AbstractMetaVariable() : m_type(0), m_hasName(false) {} |
| 622 |
AbstractMetaVariable(const AbstractMetaVariable &other); |
| 623 |
|
| 624 |
virtual ~AbstractMetaVariable() |
| 625 |
{ |
| 626 |
delete m_type; |
| 627 |
} |
| 628 |
|
| 629 |
AbstractMetaType *type() const |
| 630 |
{ |
| 631 |
return m_type; |
| 632 |
} |
| 633 |
void setType(AbstractMetaType *type) |
| 634 |
{ |
| 635 |
Q_ASSERT(m_type == 0); |
| 636 |
m_type = type; |
| 637 |
} |
| 638 |
void replaceType(AbstractMetaType *type) |
| 639 |
{ |
| 640 |
if (m_type) |
| 641 |
delete m_type; |
| 642 |
m_type = type; |
| 643 |
} |
| 644 |
|
| 645 |
QString name() const |
| 646 |
{ |
| 647 |
return m_name; |
| 648 |
} |
| 649 |
void setName(const QString &name, bool realName = true) |
| 650 |
{ |
| 651 |
m_name = name; |
| 652 |
m_hasName = realName; |
| 653 |
} |
| 654 |
bool hasName() const |
| 655 |
{ |
| 656 |
return m_hasName; |
| 657 |
} |
| 658 |
QString originalName() const |
| 659 |
{ |
| 660 |
return m_originalName; |
| 661 |
} |
| 662 |
void setOriginalName(const QString& name) |
| 663 |
{ |
| 664 |
m_originalName = name; |
| 665 |
} |
| 666 |
void setDocumentation(const Documentation& doc) |
| 667 |
{ |
| 668 |
m_doc = doc; |
| 669 |
} |
| 670 |
Documentation documentation() const |
| 671 |
{ |
| 672 |
return m_doc; |
| 673 |
} |
| 674 |
|
| 675 |
private: |
| 676 |
QString m_originalName; |
| 677 |
QString m_name; |
| 678 |
AbstractMetaType *m_type; |
| 679 |
bool m_hasName; |
| 680 |
|
| 681 |
Documentation m_doc; |
| 682 |
}; |
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
class APIEXTRACTOR_API AbstractMetaArgument : public AbstractMetaVariable |
| 687 |
{ |
| 688 |
public: |
| 689 |
AbstractMetaArgument() : m_argumentIndex(0) {}; |
| 690 |
|
| 691 |
QString defaultValueExpression() const |
| 692 |
{ |
| 693 |
return m_expression; |
| 694 |
} |
| 695 |
void setDefaultValueExpression(const QString &expr) |
| 696 |
{ |
| 697 |
m_expression = expr; |
| 698 |
} |
| 699 |
|
| 700 |
QString originalDefaultValueExpression() const |
| 701 |
{ |
| 702 |
return m_originalExpression; |
| 703 |
} |
| 704 |
void setOriginalDefaultValueExpression(const QString &expr) |
| 705 |
{ |
| 706 |
m_originalExpression = expr; |
| 707 |
} |
| 708 |
|
| 709 |
QString toString() const |
| 710 |
{ |
| 711 |
return type()->name() + " " + AbstractMetaVariable::name() + |
| 712 |
(m_expression.isEmpty() ? "" : " = " + m_expression); |
| 713 |
} |
| 714 |
|
| 715 |
int argumentIndex() const |
| 716 |
{ |
| 717 |
return m_argumentIndex; |
| 718 |
} |
| 719 |
void setArgumentIndex(int argIndex) |
| 720 |
{ |
| 721 |
m_argumentIndex = argIndex; |
| 722 |
} |
| 723 |
|
| 724 |
AbstractMetaArgument *copy() const; |
| 725 |
private: |
| 726 |
QString m_expression; |
| 727 |
QString m_originalExpression; |
| 728 |
int m_argumentIndex; |
| 729 |
|
| 730 |
friend class AbstractMetaClass; |
| 731 |
}; |
| 732 |
|
| 733 |
|
| 734 |
class APIEXTRACTOR_API AbstractMetaField : public AbstractMetaVariable, public AbstractMetaAttributes |
| 735 |
{ |
| 736 |
public: |
| 737 |
AbstractMetaField(); |
| 738 |
~AbstractMetaField(); |
| 739 |
|
| 740 |
const AbstractMetaClass *enclosingClass() const |
| 741 |
{ |
| 742 |
return m_class; |
| 743 |
} |
| 744 |
void setEnclosingClass(const AbstractMetaClass *cls) |
| 745 |
{ |
| 746 |
m_class = cls; |
| 747 |
} |
| 748 |
|
| 749 |
const AbstractMetaFunction *getter() const; |
| 750 |
const AbstractMetaFunction *setter() const; |
| 751 |
|
| 752 |
FieldModificationList modifications() const; |
| 753 |
|
| 754 |
bool isModifiedRemoved(int types = TypeSystem::All) const; |
| 755 |
|
| 756 |
using AbstractMetaVariable::setDocumentation; |
| 757 |
using AbstractMetaVariable::documentation; |
| 758 |
|
| 759 |
AbstractMetaField *copy() const; |
| 760 |
|
| 761 |
private: |
| 762 |
mutable AbstractMetaFunction *m_getter; |
| 763 |
mutable AbstractMetaFunction *m_setter; |
| 764 |
const AbstractMetaClass *m_class; |
| 765 |
}; |
| 766 |
|
| 767 |
class APIEXTRACTOR_API AbstractMetaFunction : public AbstractMetaAttributes |
| 768 |
{ |
| 769 |
public: |
| 770 |
enum FunctionType { |
| 771 |
ConstructorFunction, |
| 772 |
DestructorFunction, |
| 773 |
NormalFunction, |
| 774 |
SignalFunction, |
| 775 |
EmptyFunction, |
| 776 |
SlotFunction, |
| 777 |
GlobalScopeFunction |
| 778 |
}; |
| 779 |
|
| 780 |
enum CompareResult { |
| 781 |
EqualName = 0x00000001, |
| 782 |
EqualArguments = 0x00000002, |
| 783 |
EqualAttributes = 0x00000004, |
| 784 |
EqualImplementor = 0x00000008, |
| 785 |
EqualReturnType = 0x00000010, |
| 786 |
EqualDefaultValueOverload = 0x00000020, |
| 787 |
EqualModifiedName = 0x00000040, |
| 788 |
|
| 789 |
NameLessThan = 0x00001000, |
| 790 |
|
| 791 |
PrettySimilar = EqualName | EqualArguments, |
| 792 |
Equal = 0x0000001f, |
| 793 |
NotEqual = 0x00001000 |
| 794 |
}; |
| 795 |
|
| 796 |
AbstractMetaFunction() |
| 797 |
: m_typeEntry(0), |
| 798 |
m_functionType(NormalFunction), |
| 799 |
m_type(0), |
| 800 |
m_class(0), |
| 801 |
m_implementingClass(0), |
| 802 |
m_declaringClass(0), |
| 803 |
m_interfaceClass(0), |
| 804 |
m_propertySpec(0), |
| 805 |
m_constant(false), |
| 806 |
m_invalid(false), |
| 807 |
m_reverse(false), |
| 808 |
m_userAdded(false), |
| 809 |
m_explicit(false), |
| 810 |
m_pointerOperator(false), |
| 811 |
m_isCallOperator(false) |
| 812 |
{ |
| 813 |
} |
| 814 |
|
| 815 |
~AbstractMetaFunction(); |
| 816 |
|
| 817 |
QString name() const |
| 818 |
{ |
| 819 |
return m_name; |
| 820 |
} |
| 821 |
|
| 822 |
void setName(const QString &name) |
| 823 |
{ |
| 824 |
m_name = name; |
| 825 |
} |
| 826 |
|
| 827 |
QString originalName() const |
| 828 |
{ |
| 829 |
return m_originalName.isEmpty() ? name() : m_originalName; |
| 830 |
} |
| 831 |
|
| 832 |
void setOriginalName(const QString &name) |
| 833 |
{ |
| 834 |
m_originalName = name; |
| 835 |
} |
| 836 |
|
| 837 |
void setReverseOperator(bool reverse) |
| 838 |
{ |
| 839 |
m_reverse = reverse; |
| 840 |
} |
| 841 |
|
| 842 |
bool isReverseOperator() const |
| 843 |
{ |
| 844 |
return m_reverse; |
| 845 |
} |
| 846 |
|
| 847 |
/** |
| 848 |
* Returns true if this is a operator and the "self" operand is a pointer. |
| 849 |
* e.g. class Foo {}; operator+(SomeEnum, Foo*); |
| 850 |
*/ |
| 851 |
bool isPointerOperator() const |
| 852 |
{ |
| 853 |
return m_pointerOperator; |
| 854 |
} |
| 855 |
|
| 856 |
void setPointerOperator(bool value) |
| 857 |
{ |
| 858 |
m_pointerOperator = value; |
| 859 |
} |
| 860 |
|
| 861 |
void setExplicit(bool isExplicit) |
| 862 |
{ |
| 863 |
m_explicit = isExplicit; |
| 864 |
} |
| 865 |
/** |
| 866 |
* Says if the function (a constructor) was declared as explicit in C++. |
| 867 |
* \return true if the function was declared as explicit in C++ |
| 868 |
*/ |
| 869 |
bool isExplicit() const |
| 870 |
{ |
| 871 |
return m_explicit; |
| 872 |
} |
| 873 |
|
| 874 |
static bool isConversionOperator(QString funcName); |
| 875 |
bool isConversionOperator() const |
| 876 |
{ |
| 877 |
return isConversionOperator(originalName()); |
| 878 |
} |
| 879 |
|
| 880 |
static bool isOperatorOverload(QString funcName); |
| 881 |
bool isOperatorOverload() const |
| 882 |
{ |
| 883 |
return isOperatorOverload(originalName()); |
| 884 |
} |
| 885 |
bool isCastOperator() const; |
| 886 |
|
| 887 |
bool isArithmeticOperator() const; |
| 888 |
bool isBitwiseOperator() const; |
| 889 |
bool isComparisonOperator() const; |
| 890 |
bool isLogicalOperator() const; |
| 891 |
bool isSubscriptOperator() const; |
| 892 |
bool isAssignmentOperator() const; |
| 893 |
bool isOtherOperator() const; |
| 894 |
|
| 895 |
/** |
| 896 |
* Informs the arity of the operator or -1 if the function is not |
| 897 |
* an operator overload. |
| 898 |
* /return the arity of the operator or -1 |
| 899 |
*/ |
| 900 |
int arityOfOperator() const; |
| 901 |
bool isUnaryOperator() const { return arityOfOperator() == 1; } |
| 902 |
bool isBinaryOperator() const { return arityOfOperator() == 2; } |
| 903 |
bool isInplaceOperator() const; |
| 904 |
|
| 905 |
// TODO: ths function *should* know if it is virtual |
| 906 |
// instead of asking to your implementing class. |
| 907 |
bool isVirtual() const; |
| 908 |
bool isCopyConstructor() const; |
| 909 |
bool isThread() const; |
| 910 |
bool allowThread() const; |
| 911 |
QString modifiedName() const; |
| 912 |
|
| 913 |
QString minimalSignature() const; |
| 914 |
QStringList possibleIntrospectionCompatibleSignatures() const; |
| 915 |
|
| 916 |
QString marshalledName() const; |
| 917 |
|
| 918 |
// true if one or more of the arguments are of QtJambiObject subclasses |
| 919 |
bool argumentsHaveNativeId() const |
| 920 |
{ |
| 921 |
foreach (const AbstractMetaArgument *arg, m_arguments) { |
| 922 |
if (arg->type()->hasNativeId()) |
| 923 |
return true; |
| 924 |
} |
| 925 |
|
| 926 |
return false; |
| 927 |
} |
| 928 |
|
| 929 |
bool isModifiedRemoved(int types = TypeSystem::All) const; |
| 930 |
|
| 931 |
AbstractMetaType *type() const |
| 932 |
{ |
| 933 |
return m_type; |
| 934 |
} |
| 935 |
void setType(AbstractMetaType *type) |
| 936 |
{ |
| 937 |
Q_ASSERT(m_type == 0); |
| 938 |
m_type = type; |
| 939 |
} |
| 940 |
|
| 941 |
void replaceType(AbstractMetaType *type) |
| 942 |
{ |
| 943 |
if (m_type) |
| 944 |
delete m_type; |
| 945 |
m_type = type; |
| 946 |
} |
| 947 |
|
| 948 |
// The class that has this function as a member. |
| 949 |
const AbstractMetaClass *ownerClass() const |
| 950 |
{ |
| 951 |
return m_class; |
| 952 |
} |
| 953 |
void setOwnerClass(const AbstractMetaClass *cls) |
| 954 |
{ |
| 955 |
m_class = cls; |
| 956 |
} |
| 957 |
|
| 958 |
// The first class in a hierarchy that declares the function |
| 959 |
const AbstractMetaClass *declaringClass() const |
| 960 |
{ |
| 961 |
return m_declaringClass; |
| 962 |
} |
| 963 |
void setDeclaringClass(const AbstractMetaClass *cls) |
| 964 |
{ |
| 965 |
m_declaringClass = cls; |
| 966 |
} |
| 967 |
|
| 968 |
// The class that actually implements this function |
| 969 |
const AbstractMetaClass *implementingClass() const |
| 970 |
{ |
| 971 |
return m_implementingClass; |
| 972 |
} |
| 973 |
void setImplementingClass(const AbstractMetaClass *cls) |
| 974 |
{ |
| 975 |
m_implementingClass = cls; |
| 976 |
} |
| 977 |
|
| 978 |
bool needsCallThrough() const; |
| 979 |
|
| 980 |
AbstractMetaArgumentList arguments() const |
| 981 |
{ |
| 982 |
return m_arguments; |
| 983 |
} |
| 984 |
void setArguments(const AbstractMetaArgumentList &arguments) |
| 985 |
{ |
| 986 |
m_arguments = arguments; |
| 987 |
} |
| 988 |
void addArgument(AbstractMetaArgument *argument) |
| 989 |
{ |
| 990 |
m_arguments << argument; |
| 991 |
} |
| 992 |
int actualMinimumArgumentCount() const; |
| 993 |
|
| 994 |
void setInvalid(bool on) |
| 995 |
{ |
| 996 |
m_invalid = on; |
| 997 |
} |
| 998 |
bool isInvalid() const |
| 999 |
{ |
| 1000 |
return m_invalid; |
| 1001 |
} |
| 1002 |
bool isDeprecated() const; |
| 1003 |
bool isDestructor() const |
| 1004 |
{ |
| 1005 |
return functionType() == DestructorFunction; |
| 1006 |
} |
| 1007 |
bool isConstructor() const |
| 1008 |
{ |
| 1009 |
return functionType() == ConstructorFunction; |
| 1010 |
} |
| 1011 |
bool isNormal() const |
| 1012 |
{ |
| 1013 |
return functionType() == NormalFunction || isSlot() || isInGlobalScope(); |
| 1014 |
} |
| 1015 |
bool isInGlobalScope() const |
| 1016 |
{ |
| 1017 |
return functionType() == GlobalScopeFunction; |
| 1018 |
} |
| 1019 |
bool isSignal() const |
| 1020 |
{ |
| 1021 |
return functionType() == SignalFunction; |
| 1022 |
} |
| 1023 |
bool isSlot() const |
| 1024 |
{ |
| 1025 |
return functionType() == SlotFunction; |
| 1026 |
} |
| 1027 |
bool isEmptyFunction() const |
| 1028 |
{ |
| 1029 |
return functionType() == EmptyFunction; |
| 1030 |
} |
| 1031 |
FunctionType functionType() const |
| 1032 |
{ |
| 1033 |
return m_functionType; |
| 1034 |
} |
| 1035 |
void setFunctionType(FunctionType type) |
| 1036 |
{ |
| 1037 |
m_functionType = type; |
| 1038 |
} |
| 1039 |
|
| 1040 |
QStringList introspectionCompatibleSignatures(const QStringList &resolvedArguments = QStringList()) const; |
| 1041 |
QString signature() const; |
| 1042 |
QString targetLangSignature(bool minimal = false) const; |
| 1043 |
bool shouldReturnThisObject() const |
| 1044 |
{ |
| 1045 |
return QLatin1String("this") == argumentReplaced(0); |
| 1046 |
} |
| 1047 |
bool shouldIgnoreReturnValue() const |
| 1048 |
{ |
| 1049 |
return QLatin1String("void") == argumentReplaced(0); |
| 1050 |
} |
| 1051 |
|
| 1052 |
bool isConstant() const |
| 1053 |
{ |
| 1054 |
return m_constant; |
| 1055 |
} |
| 1056 |
void setConstant(bool constant) |
| 1057 |
{ |
| 1058 |
m_constant = constant; |
| 1059 |
} |
| 1060 |
|
| 1061 |
/// Returns true if the AbstractMetaFunction was added by the user via the type system description. |
| 1062 |
bool isUserAdded() const |
| 1063 |
{ |
| 1064 |
return m_userAdded; |
| 1065 |
} |
| 1066 |
void setUserAdded(bool userAdded) |
| 1067 |
{ |
| 1068 |
m_userAdded = userAdded; |
| 1069 |
} |
| 1070 |
|
| 1071 |
QString toString() const |
| 1072 |
{ |
| 1073 |
return m_name; |
| 1074 |
} |
| 1075 |
|
| 1076 |
uint compareTo(const AbstractMetaFunction *other) const; |
| 1077 |
|
| 1078 |
bool operator <(const AbstractMetaFunction &a) const; |
| 1079 |
|
| 1080 |
AbstractMetaFunction *copy() const; |
| 1081 |
|
| 1082 |
QString replacedDefaultExpression(const AbstractMetaClass *cls, int idx) const; |
| 1083 |
bool removedDefaultExpression(const AbstractMetaClass *cls, int idx) const; |
| 1084 |
QString conversionRule(TypeSystem::Language language, int idx) const; |
| 1085 |
QList<ReferenceCount> referenceCounts(const AbstractMetaClass *cls, int idx = -2) const; |
| 1086 |
ArgumentOwner argumentOwner(const AbstractMetaClass *cls, int idx) const; |
| 1087 |
|
| 1088 |
bool nullPointersDisabled(const AbstractMetaClass *cls = 0, int argument_idx = 0) const; |
| 1089 |
QString nullPointerDefaultValue(const AbstractMetaClass *cls = 0, int argument_idx = 0) const; |
| 1090 |
|
| 1091 |
bool resetObjectAfterUse(int argument_idx) const; |
| 1092 |
|
| 1093 |
// Returns whether garbage collection is disabled for the argument in any context |
| 1094 |
bool disabledGarbageCollection(const AbstractMetaClass *cls, int key) const; |
| 1095 |
|
| 1096 |
// Returns the ownership rules for the given argument in the given context |
| 1097 |
TypeSystem::Ownership ownership(const AbstractMetaClass *cls, TypeSystem::Language language, int idx) const; |
| 1098 |
|
| 1099 |
bool isVirtualSlot() const; |
| 1100 |
|
| 1101 |
QString typeReplaced(int argument_index) const; |
| 1102 |
bool isRemovedFromAllLanguages(const AbstractMetaClass *) const; |
| 1103 |
bool isRemovedFrom(const AbstractMetaClass *, TypeSystem::Language language) const; |
| 1104 |
bool argumentRemoved(int) const; |
| 1105 |
|
| 1106 |
QString argumentReplaced(int key) const; |
| 1107 |
bool needsSuppressUncheckedWarning() const; |
| 1108 |
|
| 1109 |
bool hasModifications(const AbstractMetaClass *implementor) const; |
| 1110 |
/** |
| 1111 |
* Verifies if any modification to the function is an inject code. |
| 1112 |
* \return true if there is inject code modifications to the function. |
| 1113 |
*/ |
| 1114 |
bool hasInjectedCode() const; |
| 1115 |
/** |
| 1116 |
* Returns a list of code snips for this function. |
| 1117 |
* The code snips can be filtered by position and language. |
| 1118 |
* \return list of code snips |
| 1119 |
*/ |
| 1120 |
CodeSnipList injectedCodeSnips(CodeSnip::Position position = CodeSnip::Any, |
| 1121 |
TypeSystem::Language language = TypeSystem::All) const; |
| 1122 |
|
| 1123 |
/** |
| 1124 |
* Verifies if any modification to the function alters/removes its |
| 1125 |
* arguments types or default values. |
| 1126 |
* \return true if there is some modification to function signature |
| 1127 |
*/ |
| 1128 |
bool hasSignatureModifications() const; |
| 1129 |
FunctionModificationList modifications(const AbstractMetaClass* implementor = 0) const; |
| 1130 |
|
| 1131 |
/** |
| 1132 |
* Return the argument name if there is a modification the renamed value will be returned |
| 1133 |
*/ |
| 1134 |
QString argumentName(int index, bool create = true, const AbstractMetaClass *cl = 0) const; |
| 1135 |
|
| 1136 |
// If this function stems from an interface, this returns the |
| 1137 |
// interface that declares it. |
| 1138 |
const AbstractMetaClass *interfaceClass() const |
| 1139 |
{ |
| 1140 |
return m_interfaceClass; |
| 1141 |
} |
| 1142 |
|
| 1143 |
void setInterfaceClass(const AbstractMetaClass *cl) |
| 1144 |
{ |
| 1145 |
m_interfaceClass = cl; |
| 1146 |
} |
| 1147 |
|
| 1148 |
void setPropertySpec(QPropertySpec *spec) |
| 1149 |
{ |
| 1150 |
m_propertySpec = spec; |
| 1151 |
} |
| 1152 |
|
| 1153 |
QPropertySpec *propertySpec() const |
| 1154 |
{ |
| 1155 |
return m_propertySpec; |
| 1156 |
} |
| 1157 |
|
| 1158 |
FunctionTypeEntry* typeEntry() const |
| 1159 |
{ |
| 1160 |
return m_typeEntry; |
| 1161 |
} |
| 1162 |
|
| 1163 |
void setTypeEntry(FunctionTypeEntry* typeEntry) |
| 1164 |
{ |
| 1165 |
m_typeEntry = typeEntry; |
| 1166 |
} |
| 1167 |
|
| 1168 |
bool isCallOperator() const; |
| 1169 |
private: |
| 1170 |
QString m_name; |
| 1171 |
QString m_originalName; |
| 1172 |
mutable QString m_cachedMinimalSignature; |
| 1173 |
mutable QString m_cachedSignature; |
| 1174 |
mutable QString m_cachedModifiedName; |
| 1175 |
|
| 1176 |
FunctionTypeEntry* m_typeEntry; |
| 1177 |
FunctionType m_functionType; |
| 1178 |
AbstractMetaType *m_type; |
| 1179 |
const AbstractMetaClass *m_class; |
| 1180 |
const AbstractMetaClass *m_implementingClass; |
| 1181 |
const AbstractMetaClass *m_declaringClass; |
| 1182 |
const AbstractMetaClass *m_interfaceClass; |
| 1183 |
QPropertySpec *m_propertySpec; |
| 1184 |
AbstractMetaArgumentList m_arguments; |
| 1185 |
uint m_constant : 1; |
| 1186 |
uint m_invalid : 1; |
| 1187 |
uint m_reverse : 1; |
| 1188 |
uint m_userAdded : 1; |
| 1189 |
uint m_explicit : 1; |
| 1190 |
uint m_pointerOperator : 1; |
| 1191 |
uint m_isCallOperator : 1; |
| 1192 |
}; |
| 1193 |
|
| 1194 |
|
| 1195 |
class AbstractMetaEnumValue |
| 1196 |
{ |
| 1197 |
public: |
| 1198 |
AbstractMetaEnumValue() |
| 1199 |
: m_valueSet(false), m_value(0) |
| 1200 |
{ |
| 1201 |
} |
| 1202 |
|
| 1203 |
int value() const |
| 1204 |
{ |
| 1205 |
return m_value; |
| 1206 |
} |
| 1207 |
|
| 1208 |
void setValue(int value) |
| 1209 |
{ |
| 1210 |
m_valueSet = true; |
| 1211 |
m_value = value; |
| 1212 |
} |
| 1213 |
|
| 1214 |
QString stringValue() const |
| 1215 |
{ |
| 1216 |
return m_stringValue; |
| 1217 |
} |
| 1218 |
|
| 1219 |
void setStringValue(const QString &v) |
| 1220 |
{ |
| 1221 |
m_stringValue = v; |
| 1222 |
} |
| 1223 |
|
| 1224 |
QString name() const |
| 1225 |
{ |
| 1226 |
return m_name; |
| 1227 |
} |
| 1228 |
|
| 1229 |
void setName(const QString &name) |
| 1230 |
{ |
| 1231 |
m_name = name; |
| 1232 |
} |
| 1233 |
|
| 1234 |
bool isValueSet() const |
| 1235 |
{ |
| 1236 |
return m_valueSet; |
| 1237 |
} |
| 1238 |
|
| 1239 |
void setDocumentation(const Documentation& doc) |
| 1240 |
{ |
| 1241 |
m_doc = doc; |
| 1242 |
} |
| 1243 |
|
| 1244 |
Documentation documentation() const |
| 1245 |
{ |
| 1246 |
return m_doc; |
| 1247 |
} |
| 1248 |
|
| 1249 |
private: |
| 1250 |
QString m_name; |
| 1251 |
QString m_stringValue; |
| 1252 |
|
| 1253 |
bool m_valueSet; |
| 1254 |
int m_value; |
| 1255 |
|
| 1256 |
Documentation m_doc; |
| 1257 |
}; |
| 1258 |
|
| 1259 |
|
| 1260 |
class AbstractMetaEnumValueList : public QList<AbstractMetaEnumValue *> |
| 1261 |
{ |
| 1262 |
public: |
| 1263 |
AbstractMetaEnumValue *find(const QString &name) const; |
| 1264 |
}; |
| 1265 |
|
| 1266 |
class AbstractMetaEnum : public AbstractMetaAttributes |
| 1267 |
{ |
| 1268 |
public: |
| 1269 |
AbstractMetaEnum() : m_typeEntry(0), m_class(0), m_hasQenumsDeclaration(false) {} |
| 1270 |
~AbstractMetaEnum() |
| 1271 |
{ |
| 1272 |
qDeleteAll(m_enumValues); |
| 1273 |
} |
| 1274 |
|
| 1275 |
AbstractMetaEnumValueList values() const |
| 1276 |
{ |
| 1277 |
return m_enumValues; |
| 1278 |
} |
| 1279 |
|
| 1280 |
void addEnumValue(AbstractMetaEnumValue *enumValue) |
| 1281 |
{ |
| 1282 |
m_enumValues << enumValue; |
| 1283 |
} |
| 1284 |
|
| 1285 |
QString name() const |
| 1286 |
{ |
| 1287 |
return m_typeEntry->targetLangName(); |
| 1288 |
} |
| 1289 |
|
| 1290 |
QString qualifier() const |
| 1291 |
{ |
| 1292 |
return m_typeEntry->targetLangQualifier(); |
| 1293 |
} |
| 1294 |
|
| 1295 |
QString package() const |
| 1296 |
{ |
| 1297 |
return m_typeEntry->targetLangPackage(); |
| 1298 |
} |
| 1299 |
|
| 1300 |
QString fullName() const |
| 1301 |
{ |
| 1302 |
return package() + "." + qualifier() + "." + name(); |
| 1303 |
} |
| 1304 |
|
| 1305 |
// Has the enum been declared inside a Q_ENUMS() macro in its enclosing class? |
| 1306 |
void setHasQEnumsDeclaration(bool on) |
| 1307 |
{ |
| 1308 |
m_hasQenumsDeclaration = on; |
| 1309 |
} |
| 1310 |
|
| 1311 |
bool hasQEnumsDeclaration() const |
| 1312 |
{ |
| 1313 |
return m_hasQenumsDeclaration; |
| 1314 |
} |
| 1315 |
|
| 1316 |
EnumTypeEntry *typeEntry() const |
| 1317 |
{ |
| 1318 |
return m_typeEntry; |
| 1319 |
} |
| 1320 |
|
| 1321 |
void setTypeEntry(EnumTypeEntry *entry) |
| 1322 |
{ |
| 1323 |
m_typeEntry = entry; |
| 1324 |
} |
| 1325 |
|
| 1326 |
AbstractMetaClass *enclosingClass() const |
| 1327 |
{ |
| 1328 |
return m_class; |
| 1329 |
} |
| 1330 |
|
| 1331 |
void setEnclosingClass(AbstractMetaClass *c) |
| 1332 |
{ |
| 1333 |
m_class = c; |
| 1334 |
} |
| 1335 |
|
| 1336 |
bool isAnonymous() const |
| 1337 |
{ |
| 1338 |
return m_typeEntry->isAnonymous(); |
| 1339 |
} |
| 1340 |
|
| 1341 |
private: |
| 1342 |
AbstractMetaEnumValueList m_enumValues; |
| 1343 |
EnumTypeEntry *m_typeEntry; |
| 1344 |
AbstractMetaClass *m_class; |
| 1345 |
|
| 1346 |
uint m_hasQenumsDeclaration : 1; |
| 1347 |
uint m_reserved : 31; |
| 1348 |
}; |
| 1349 |
|
| 1350 |
typedef QList<AbstractMetaEnum *> AbstractMetaEnumList; |
| 1351 |
|
| 1352 |
class APIEXTRACTOR_API AbstractMetaClass : public AbstractMetaAttributes |
| 1353 |
{ |
| 1354 |
public: |
| 1355 |
enum FunctionQueryOption { |
| 1356 |
Constructors = 0x0000001, // Only constructors |
| 1357 |
//Destructors = 0x0000002, // Only destructors. Not included in class. |
| 1358 |
VirtualFunctions = 0x0000004, // Only virtual functions (virtual in both TargetLang and C++) |
| 1359 |
FinalInTargetLangFunctions = 0x0000008, // Only functions that are non-virtual in TargetLang |
| 1360 |
FinalInCppFunctions = 0x0000010, // Only functions that are non-virtual in C++ |
| 1361 |
ClassImplements = 0x0000020, // Only functions implemented by the current class |
| 1362 |
Inconsistent = 0x0000040, // Only inconsistent functions (inconsistent virtualness in TargetLang/C++) |
| 1363 |
StaticFunctions = 0x0000080, // Only static functions |
| 1364 |
Signals = 0x0000100, // Only signals |
| 1365 |
NormalFunctions = 0x0000200, // Only functions that aren't signals |
| 1366 |
Visible = 0x0000400, // Only public and protected functions |
| 1367 |
ForcedShellFunctions = 0x0000800, // Only functions that are overridden to be implemented in the shell class |
| 1368 |
WasPublic = 0x0001000, // Only functions that were originally public |
| 1369 |
WasProtected = 0x0002000, // Only functions that were originally protected |
| 1370 |
NonStaticFunctions = 0x0004000, // No static functions |
| 1371 |
Empty = 0x0008000, // Empty overrides of abstract functions |
| 1372 |
Invisible = 0x0010000, // Only private functions |
| 1373 |
VirtualInCppFunctions = 0x0020000, // Only functions that are virtual in C++ |
| 1374 |
NonEmptyFunctions = 0x0040000, // Only functions with target language API implementations |
| 1375 |
VirtualInTargetLangFunctions = 0x0080000, // Only functions which are virtual in TargetLang |
| 1376 |
AbstractFunctions = 0x0100000, // Only abstract functions |
| 1377 |
WasVisible = 0x0200000, // Only functions that were public or protected in the original code |
| 1378 |
NotRemovedFromTargetLang = 0x0400000, // Only functions that have not been removed from TargetLang |
| 1379 |
NotRemovedFromShell = 0x0800000, // Only functions that have not been removed from the shell class |
| 1380 |
VirtualSlots = 0x1000000, // Only functions that are set as virtual slots in the type system |
| 1381 |
OperatorOverloads = 0x2000000 // Only functions that are operator overloads |
| 1382 |
}; |
| 1383 |
|
| 1384 |
enum OperatorQueryOption { |
| 1385 |
ArithmeticOp = 0x01, // Arithmetic: +, -, *, /, %, +=, -=, *=, /=, %=, ++, --, unary+, unary- |
| 1386 |
BitwiseOp = 0x02, // Bitwise: <<, <<=, >>, >>=, ~, &, &=, |, |=, ^, ^= |
| 1387 |
ComparisonOp = 0x04, // Comparison: <, <=, >, >=, !=, == |
| 1388 |
LogicalOp = 0x08, // Logical: !, &&, || |
| 1389 |
ConversionOp = 0x10, // Conversion: operator [const] TYPE() |
| 1390 |
SubscriptionOp = 0x20, // Subscription: [] |
| 1391 |
AssignmentOp = 0x40, // Assignment: = |
| 1392 |
OtherOp = 0x80, // The remaining operators: call(), etc |
| 1393 |
AllOperators = ArithmeticOp | BitwiseOp | ComparisonOp |
| 1394 |
| LogicalOp | ConversionOp | SubscriptionOp |
| 1395 |
| AssignmentOp | OtherOp |
| 1396 |
}; |
| 1397 |
|
| 1398 |
AbstractMetaClass() |
| 1399 |
: m_namespace(false), |
| 1400 |
m_qobject(false), |
| 1401 |
m_hasVirtuals(false), |
| 1402 |
m_isPolymorphic(false), |
| 1403 |
m_hasNonpublic(false), |
| 1404 |
m_hasVirtualSlots(false), |
| 1405 |
m_hasNonPrivateConstructor(false), |
| 1406 |
m_functionsFixed(false), |
| 1407 |
m_hasPrivateDestructor(false), |
| 1408 |
m_hasProtectedDestructor(false), |
| 1409 |
m_hasVirtualDestructor(false), |
| 1410 |
m_forceShellClass(false), |
| 1411 |
m_hasHashFunction(false), |
| 1412 |
m_hasEqualsOperator(false), |
| 1413 |
m_hasCloneOperator(false), |
| 1414 |
m_isTypeAlias(false), |
| 1415 |
m_hasToStringCapability(false), |
| 1416 |
m_enclosingClass(0), |
| 1417 |
m_baseClass(0), |
| 1418 |
m_templateBaseClass(0), |
| 1419 |
m_extractedInterface(0), |
| 1420 |
m_primaryInterfaceImplementor(0), |
| 1421 |
m_typeEntry(0), |
| 1422 |
m_stream(false) |
| 1423 |
{ |
| 1424 |
} |
| 1425 |
|
| 1426 |
virtual ~AbstractMetaClass(); |
| 1427 |
|
| 1428 |
AbstractMetaClass *extractInterface(); |
| 1429 |
void fixFunctions(); |
| 1430 |
|
| 1431 |
AbstractMetaFunctionList functions() const |
| 1432 |
{ |
| 1433 |
return m_functions; |
| 1434 |
} |
| 1435 |
|
| 1436 |
void setFunctions(const AbstractMetaFunctionList &functions); |
| 1437 |
void addFunction(AbstractMetaFunction *function); |
| 1438 |
bool hasFunction(const AbstractMetaFunction *f) const; |
| 1439 |
bool hasFunction(const QString &str) const; |
| 1440 |
const AbstractMetaFunction* findFunction(const QString& functionName) const; |
| 1441 |
bool hasSignal(const AbstractMetaFunction *f) const; |
| 1442 |
|
| 1443 |
bool hasConstructors() const; |
| 1444 |
bool hasCopyConstructor() const; |
| 1445 |
bool hasPrivateCopyConstructor() const; |
| 1446 |
|
| 1447 |
void addDefaultConstructor(); |
| 1448 |
void addDefaultCopyConstructor(bool isPrivate = false); |
| 1449 |
|
| 1450 |
bool hasNonPrivateConstructor() const |
| 1451 |
{ |
| 1452 |
return m_hasNonPrivateConstructor; |
| 1453 |
} |
| 1454 |
|
| 1455 |
void setHasNonPrivateConstructor(bool value) |
| 1456 |
{ |
| 1457 |
m_hasNonPrivateConstructor = value; |
| 1458 |
} |
| 1459 |
|
| 1460 |
bool hasPrivateDestructor() const |
| 1461 |
{ |
| 1462 |
return m_hasPrivateDestructor; |
| 1463 |
} |
| 1464 |
|
| 1465 |
void setHasPrivateDestructor(bool value) |
| 1466 |
{ |
| 1467 |
m_hasPrivateDestructor = value; |
| 1468 |
} |
| 1469 |
|
| 1470 |
bool hasProtectedDestructor() const |
| 1471 |
{ |
| 1472 |
return m_hasProtectedDestructor; |
| 1473 |
} |
| 1474 |
|
| 1475 |
void setHasProtectedDestructor(bool value) |
| 1476 |
{ |
| 1477 |
m_hasProtectedDestructor = value; |
| 1478 |
} |
| 1479 |
|
| 1480 |
bool hasVirtualDestructor() const |
| 1481 |
{ |
| 1482 |
return m_hasVirtualDestructor; |
| 1483 |
} |
| 1484 |
|
| 1485 |
void setHasVirtualDestructor(bool value) |
| 1486 |
{ |
| 1487 |
m_hasVirtualDestructor = value; |
| 1488 |
} |
| 1489 |
|
| 1490 |
AbstractMetaFunctionList queryFunctionsByName(const QString &name) const; |
| 1491 |
AbstractMetaFunctionList queryFunctions(uint query) const; |
| 1492 |
inline AbstractMetaFunctionList allVirtualFunctions() const; |
| 1493 |
inline AbstractMetaFunctionList allFinalFunctions() const; |
| 1494 |
AbstractMetaFunctionList functionsInTargetLang() const; |
| 1495 |
AbstractMetaFunctionList functionsInShellClass() const; |
| 1496 |
inline AbstractMetaFunctionList cppInconsistentFunctions() const; |
| 1497 |
inline AbstractMetaFunctionList cppSignalFunctions() const; |
| 1498 |
AbstractMetaFunctionList publicOverrideFunctions() const; |
| 1499 |
AbstractMetaFunctionList virtualOverrideFunctions() const; |
| 1500 |
AbstractMetaFunctionList virtualFunctions() const; |
| 1501 |
AbstractMetaFunctionList nonVirtualShellFunctions() const; |
| 1502 |
AbstractMetaFunctionList implicitConversions() const; |
| 1503 |
|
| 1504 |
/** |
| 1505 |
* Retrieves all class' operator overloads that meet |
| 1506 |
* query criteria defined with the OperatorQueryOption |
| 1507 |
* enum. |
| 1508 |
* /param query composition of OperatorQueryOption enum values |
| 1509 |
* /return list of operator overload methods that meet the |
| 1510 |
* query criteria |
| 1511 |
*/ |
| 1512 |
AbstractMetaFunctionList operatorOverloads(uint query = AllOperators) const; |
| 1513 |
|
| 1514 |
bool hasOperatorOverload() const; |
| 1515 |
bool hasArithmeticOperatorOverload() const; |
| 1516 |
bool hasBitwiseOperatorOverload() const; |
| 1517 |
bool hasComparisonOperatorOverload() const; |
| 1518 |
bool hasLogicalOperatorOverload() const; |
| 1519 |
bool hasSubscriptOperatorOverload() const; |
| 1520 |
bool hasAssignmentOperatorOverload() const; |
| 1521 |
bool hasConversionOperatorOverload() const; |
| 1522 |
|
| 1523 |
AbstractMetaFieldList fields() const |
| 1524 |
{ |
| 1525 |
return m_fields; |
| 1526 |
} |
| 1527 |
|
| 1528 |
void setFields(const AbstractMetaFieldList &fields) |
| 1529 |
{ |
| 1530 |
m_fields = fields; |
| 1531 |
} |
| 1532 |
|
| 1533 |
void addField(AbstractMetaField *field) |
| 1534 |
{ |
| 1535 |
m_fields << field; |
| 1536 |
} |
| 1537 |
|
| 1538 |
AbstractMetaEnumList enums() const |
| 1539 |
{ |
| 1540 |
return m_enums; |
| 1541 |
} |
| 1542 |
void setEnums(const AbstractMetaEnumList &enums) |
| 1543 |
{ |
| 1544 |
m_enums = enums; |
| 1545 |
} |
| 1546 |
|
| 1547 |
void addEnum(AbstractMetaEnum *e) |
| 1548 |
{ |
| 1549 |
m_enums << e; |
| 1550 |
} |
| 1551 |
|
| 1552 |
AbstractMetaEnum *findEnum(const QString &enumName); |
| 1553 |
AbstractMetaEnum *findEnumForValue(const QString &enumName); |
| 1554 |
AbstractMetaEnumValue *findEnumValue(const QString &enumName, AbstractMetaEnum *meta_enum); |
| 1555 |
|
| 1556 |
AbstractMetaClassList interfaces() const |
| 1557 |
{ |
| 1558 |
return m_interfaces; |
| 1559 |
} |
| 1560 |
void addInterface(AbstractMetaClass *interface); |
| 1561 |
void setInterfaces(const AbstractMetaClassList &interface); |
| 1562 |
|
| 1563 |
QString fullName() const |
| 1564 |
{ |
| 1565 |
return package() + "." + name(); |
| 1566 |
} |
| 1567 |
|
| 1568 |
/** |
| 1569 |
* Retrieves the class name without any namespace/scope information. |
| 1570 |
* /return the class name without scope information |
| 1571 |
*/ |
| 1572 |
QString name() const; |
| 1573 |
|
| 1574 |
QString baseClassName() const |
| 1575 |
{ |
| 1576 |
return m_baseClass ? m_baseClass->name() : QString(); |
| 1577 |
} |
| 1578 |
|
| 1579 |
AbstractMetaClass *baseClass() const |
| 1580 |
{ |
| 1581 |
return m_baseClass; |
| 1582 |
} |
| 1583 |
|
| 1584 |
void setBaseClass(AbstractMetaClass *base_class); |
| 1585 |
|
| 1586 |
const AbstractMetaClass *enclosingClass() const |
| 1587 |
{ |
| 1588 |
return m_enclosingClass; |
| 1589 |
} |
| 1590 |
|
| 1591 |
void setEnclosingClass(AbstractMetaClass *cl) |
| 1592 |
{ |
| 1593 |
m_enclosingClass = cl; |
| 1594 |
} |
| 1595 |
|
| 1596 |
const AbstractMetaClassList& innerClasses() const |
| 1597 |
{ |
| 1598 |
return m_innerClasses; |
| 1599 |
} |
| 1600 |
|
| 1601 |
void addInnerClass(AbstractMetaClass* cl) |
| 1602 |
{ |
| 1603 |
m_innerClasses << cl; |
| 1604 |
} |
| 1605 |
|
| 1606 |
void setInnerClasses(AbstractMetaClassList innerClasses) |
| 1607 |
{ |
| 1608 |
m_innerClasses = innerClasses; |
| 1609 |
} |
| 1610 |
|
| 1611 |
QString package() const |
| 1612 |
{ |
| 1613 |
return m_typeEntry->targetLangPackage(); |
| 1614 |
} |
| 1615 |
|
| 1616 |
bool isInterface() const |
| 1617 |
{ |
| 1618 |
return m_typeEntry->isInterface(); |
| 1619 |
} |
| 1620 |
|
| 1621 |
bool isNamespace() const |
| 1622 |
{ |
| 1623 |
return m_typeEntry->isNamespace(); |
| 1624 |
} |
| 1625 |
|
| 1626 |
bool isQObject() const |
| 1627 |
{ |
| 1628 |
return m_typeEntry->isQObject(); |
| 1629 |
} |
| 1630 |
|
| 1631 |
bool isQtNamespace() const |
| 1632 |
{ |
| 1633 |
return isNamespace() && name() == "Qt"; |
| 1634 |
} |
| 1635 |
|
| 1636 |
QString qualifiedCppName() const |
| 1637 |
{ |
| 1638 |
return m_typeEntry->qualifiedCppName(); |
| 1639 |
} |
| 1640 |
|
| 1641 |
bool hasInconsistentFunctions() const; |
| 1642 |
bool hasSignals() const; |
| 1643 |
bool inheritsFrom(const AbstractMetaClass *other) const; |
| 1644 |
|
| 1645 |
void setForceShellClass(bool on) |
| 1646 |
{ |
| 1647 |
m_forceShellClass = on; |
| 1648 |
} |
| 1649 |
|
| 1650 |
bool generateShellClass() const; |
| 1651 |
|
| 1652 |
bool hasVirtualSlots() const |
| 1653 |
{ |
| 1654 |
return m_hasVirtualSlots; |
| 1655 |
} |
| 1656 |
|
| 1657 |
/** |
| 1658 |
* Says if a class has any virtual functions of its own. |
| 1659 |
* \return true if the class implements any virtual methods |
| 1660 |
*/ |
| 1661 |
bool hasVirtualFunctions() const |
| 1662 |
{ |
| 1663 |
return !isFinal() && m_hasVirtuals; |
| 1664 |
} |
| 1665 |
/** |
| 1666 |
* Says if the class that declares or inherits a virtual function. |
| 1667 |
* \return true if the class implements or inherits any virtual methods |
| 1668 |
*/ |
| 1669 |
bool isPolymorphic() const |
| 1670 |
{ |
| 1671 |
return m_isPolymorphic; |
| 1672 |
} |
| 1673 |
|
| 1674 |
/** |
| 1675 |
* Tells if this class has one or more functions that are protected. |
| 1676 |
* \return true if the class has protected functions. |
| 1677 |
*/ |
| 1678 |
bool hasProtectedFunctions() const; |
| 1679 |
|
| 1680 |
/** |
| 1681 |
* Tells if this class has one or more fields (member variables) that are protected. |
| 1682 |
* \return true if the class has protected fields. |
| 1683 |
*/ |
| 1684 |
bool hasProtectedFields() const; |
| 1685 |
|
| 1686 |
/** |
| 1687 |
* Tells if this class has one or more members (functions or fields) that are protected. |
| 1688 |
* \return true if the class has protected members. |
| 1689 |
*/ |
| 1690 |
bool hasProtectedMembers() const; |
| 1691 |
|
| 1692 |
|
| 1693 |
QList<TypeEntry *> templateArguments() const |
| 1694 |
{ |
| 1695 |
return m_templateArgs; |
| 1696 |
} |
| 1697 |
|
| 1698 |
void setTemplateArguments(const QList<TypeEntry *> &args) |
| 1699 |
{ |
| 1700 |
m_templateArgs = args; |
| 1701 |
} |
| 1702 |
|
| 1703 |
bool hasFieldAccessors() const; |
| 1704 |
|
| 1705 |
// only valid during metabuilder's run |
| 1706 |
QStringList baseClassNames() const |
| 1707 |
{ |
| 1708 |
return m_baseClassNames; |
| 1709 |
} |
| 1710 |
|
| 1711 |
void setBaseClassNames(const QStringList &names) |
| 1712 |
{ |
| 1713 |
m_baseClassNames = names; |
| 1714 |
} |
| 1715 |
|
| 1716 |
AbstractMetaClass *primaryInterfaceImplementor() const |
| 1717 |
{ |
| 1718 |
return m_primaryInterfaceImplementor; |
| 1719 |
} |
| 1720 |
|
| 1721 |
void setPrimaryInterfaceImplementor(AbstractMetaClass *cl) |
| 1722 |
{ |
| 1723 |
m_primaryInterfaceImplementor = cl; |
| 1724 |
} |
| 1725 |
|
| 1726 |
const ComplexTypeEntry *typeEntry() const |
| 1727 |
{ |
| 1728 |
return m_typeEntry; |
| 1729 |
} |
| 1730 |
|
| 1731 |
ComplexTypeEntry *typeEntry() |
| 1732 |
{ |
| 1733 |
return m_typeEntry; |
| 1734 |
} |
| 1735 |
|
| 1736 |
void setTypeEntry(ComplexTypeEntry *type) |
| 1737 |
{ |
| 1738 |
m_typeEntry = type; |
| 1739 |
} |
| 1740 |
|
| 1741 |
void setHasHashFunction(bool on) |
| 1742 |
{ |
| 1743 |
m_hasHashFunction = on; |
| 1744 |
} |
| 1745 |
|
| 1746 |
bool hasHashFunction() const |
| 1747 |
{ |
| 1748 |
return m_hasHashFunction; |
| 1749 |
} |
| 1750 |
virtual bool hasDefaultToStringFunction() const; |
| 1751 |
|
| 1752 |
void setHasEqualsOperator(bool on) |
| 1753 |
{ |
| 1754 |
m_hasEqualsOperator = on; |
| 1755 |
} |
| 1756 |
|
| 1757 |
bool hasEqualsOperator() const |
| 1758 |
{ |
| 1759 |
return m_hasEqualsOperator; |
| 1760 |
} |
| 1761 |
|
| 1762 |
void setHasCloneOperator(bool on) |
| 1763 |
{ |
| 1764 |
m_hasCloneOperator = on; |
| 1765 |
} |
| 1766 |
|
| 1767 |
bool hasCloneOperator() const |
| 1768 |
{ |
| 1769 |
return m_hasCloneOperator; |
| 1770 |
} |
| 1771 |
|
| 1772 |
void addPropertySpec(QPropertySpec *spec) |
| 1773 |
{ |
| 1774 |
m_propertySpecs << spec; |
| 1775 |
} |
| 1776 |
|
| 1777 |
QList<QPropertySpec *> propertySpecs() const |
| 1778 |
{ |
| 1779 |
return m_propertySpecs; |
| 1780 |
} |
| 1781 |
|
| 1782 |
QPropertySpec *propertySpecForRead(const QString &name) const; |
| 1783 |
QPropertySpec *propertySpecForWrite(const QString &name) const; |
| 1784 |
QPropertySpec *propertySpecForReset(const QString &name) const; |
| 1785 |
|
| 1786 |
QList<ReferenceCount> referenceCounts() const; |
| 1787 |
|
| 1788 |
void setEqualsFunctions(const AbstractMetaFunctionList &lst) |
| 1789 |
{ |
| 1790 |
m_equalsFunctions = lst; |
| 1791 |
} |
| 1792 |
|
| 1793 |
AbstractMetaFunctionList equalsFunctions() const |
| 1794 |
{ |
| 1795 |
return m_equalsFunctions; |
| 1796 |
} |
| 1797 |
|
| 1798 |
void setNotEqualsFunctions(const AbstractMetaFunctionList &lst) |
| 1799 |
{ |
| 1800 |
m_nequalsFunctions = lst; |
| 1801 |
} |
| 1802 |
|
| 1803 |
AbstractMetaFunctionList notEqualsFunctions() const |
| 1804 |
{ |
| 1805 |
return m_nequalsFunctions; |
| 1806 |
} |
| 1807 |
|
| 1808 |
void setLessThanFunctions(const AbstractMetaFunctionList &lst) |
| 1809 |
{ |
| 1810 |
m_lessThanFunctions = lst; |
| 1811 |
} |
| 1812 |
|
| 1813 |
AbstractMetaFunctionList lessThanFunctions() const |
| 1814 |
{ |
| 1815 |
return m_lessThanFunctions; |
| 1816 |
} |
| 1817 |
|
| 1818 |
void setGreaterThanFunctions(const AbstractMetaFunctionList &lst) |
| 1819 |
{ |
| 1820 |
m_greaterThanFunctions = lst; |
| 1821 |
} |
| 1822 |
|
| 1823 |
AbstractMetaFunctionList greaterThanFunctions() const |
| 1824 |
{ |
| 1825 |
return m_greaterThanFunctions; |
| 1826 |
} |
| 1827 |
|
| 1828 |
void setLessThanEqFunctions(const AbstractMetaFunctionList &lst) |
| 1829 |
{ |
| 1830 |
m_lessThanEqFunctions = lst; |
| 1831 |
} |
| 1832 |
|
| 1833 |
AbstractMetaFunctionList lessThanEqFunctions() const |
| 1834 |
{ |
| 1835 |
return m_lessThanEqFunctions; |
| 1836 |
} |
| 1837 |
|
| 1838 |
void setGreaterThanEqFunctions(const AbstractMetaFunctionList &lst) |
| 1839 |
{ |
| 1840 |
m_greaterThanEqFunctions = lst; |
| 1841 |
} |
| 1842 |
|
| 1843 |
AbstractMetaFunctionList greaterThanEqFunctions() const |
| 1844 |
{ |
| 1845 |
return m_greaterThanEqFunctions; |
| 1846 |
} |
| 1847 |
|
| 1848 |
/// Returns a list of conversion operators for this class. The conversion operators are defined in other classes of the same module. |
| 1849 |
AbstractMetaFunctionList externalConversionOperators() const |
| 1850 |
{ |
| 1851 |
return m_externalConversionOperators; |
| 1852 |
} |
| 1853 |
/// Adds a converter operator for this class. |
| 1854 |
void addExternalConversionOperator(AbstractMetaFunction* conversionOp) |
| 1855 |
{ |
| 1856 |
if (!m_externalConversionOperators.contains(conversionOp)) |
| 1857 |
m_externalConversionOperators.append(conversionOp); |
| 1858 |
} |
| 1859 |
/// Returns true if this class has any converter operators defined elsewhere. |
| 1860 |
bool hasExternalConversionOperators() const |
| 1861 |
{ |
| 1862 |
return !m_externalConversionOperators.isEmpty(); |
| 1863 |
} |
| 1864 |
|
| 1865 |
void sortFunctions(); |
| 1866 |
|
| 1867 |
const AbstractMetaClass *templateBaseClass() const |
| 1868 |
{ |
| 1869 |
return m_templateBaseClass; |
| 1870 |
} |
| 1871 |
|
| 1872 |
void setTemplateBaseClass(const AbstractMetaClass *cls) |
| 1873 |
{ |
| 1874 |
m_templateBaseClass = cls; |
| 1875 |
} |
| 1876 |
|
| 1877 |
bool hasTemplateBaseClassInstantiations() const; |
| 1878 |
AbstractMetaTypeList templateBaseClassInstantiations() const; |
| 1879 |
void setTemplateBaseClassInstantiations(AbstractMetaTypeList& instantiations); |
| 1880 |
|
| 1881 |
void setTypeAlias(bool typeAlias) |
| 1882 |
{ |
| 1883 |
m_isTypeAlias = typeAlias; |
| 1884 |
} |
| 1885 |
|
| 1886 |
bool isTypeAlias() const |
| 1887 |
{ |
| 1888 |
return m_isTypeAlias; |
| 1889 |
} |
| 1890 |
|
| 1891 |
void setStream(bool stream) |
| 1892 |
{ |
| 1893 |
m_stream = stream; |
| 1894 |
} |
| 1895 |
|
| 1896 |
bool isStream() const |
| 1897 |
{ |
| 1898 |
return m_stream; |
| 1899 |
} |
| 1900 |
|
| 1901 |
void setToStringCapability(bool value) |
| 1902 |
{ |
| 1903 |
m_hasToStringCapability = value; |
| 1904 |
} |
| 1905 |
|
| 1906 |
bool hasToStringCapability() const |
| 1907 |
{ |
| 1908 |
return m_hasToStringCapability; |
| 1909 |
} |
| 1910 |
private: |
| 1911 |
uint m_namespace : 1; |
| 1912 |
uint m_qobject : 1; |
| 1913 |
uint m_hasVirtuals : 1; |
| 1914 |
uint m_isPolymorphic : 1; |
| 1915 |
uint m_hasNonpublic : 1; |
| 1916 |
uint m_hasVirtualSlots : 1; |
| 1917 |
uint m_hasNonPrivateConstructor : 1; |
| 1918 |
uint m_functionsFixed : 1; |
| 1919 |
uint m_hasPrivateDestructor : 1; |
| 1920 |
uint m_hasProtectedDestructor : 1; |
| 1921 |
uint m_hasVirtualDestructor : 1; |
| 1922 |
uint m_forceShellClass : 1; |
| 1923 |
uint m_hasHashFunction : 1; |
| 1924 |
uint m_hasEqualsOperator : 1; |
| 1925 |
uint m_hasCloneOperator : 1; |
| 1926 |
uint m_isTypeAlias : 1; |
| 1927 |
uint m_hasToStringCapability : 1; |
| 1928 |
uint m_reserved : 17; |
| 1929 |
|
| 1930 |
const AbstractMetaClass *m_enclosingClass; |
| 1931 |
AbstractMetaClass *m_baseClass; |
| 1932 |
const AbstractMetaClass *m_templateBaseClass; |
| 1933 |
AbstractMetaFunctionList m_functions; |
| 1934 |
AbstractMetaFieldList m_fields; |
| 1935 |
AbstractMetaEnumList m_enums; |
| 1936 |
AbstractMetaClassList m_interfaces; |
| 1937 |
AbstractMetaClassList m_orphanInterfaces; |
| 1938 |
AbstractMetaClass *m_extractedInterface; |
| 1939 |
AbstractMetaClass *m_primaryInterfaceImplementor; |
| 1940 |
QList<QPropertySpec *> m_propertySpecs; |
| 1941 |
AbstractMetaFunctionList m_equalsFunctions; |
| 1942 |
AbstractMetaFunctionList m_nequalsFunctions; |
| 1943 |
AbstractMetaClassList m_innerClasses; |
| 1944 |
|
| 1945 |
AbstractMetaFunctionList m_lessThanFunctions; |
| 1946 |
AbstractMetaFunctionList m_greaterThanFunctions; |
| 1947 |
AbstractMetaFunctionList m_lessThanEqFunctions; |
| 1948 |
AbstractMetaFunctionList m_greaterThanEqFunctions; |
| 1949 |
|
| 1950 |
AbstractMetaFunctionList m_externalConversionOperators; |
| 1951 |
|
| 1952 |
QStringList m_baseClassNames; |
| 1953 |
QList<TypeEntry *> m_templateArgs; |
| 1954 |
ComplexTypeEntry *m_typeEntry; |
| 1955 |
// FunctionModelItem m_qDebugStreamFunction; |
| 1956 |
|
| 1957 |
bool m_stream; |
| 1958 |
static int m_count; |
| 1959 |
}; |
| 1960 |
|
| 1961 |
class QPropertySpec |
| 1962 |
{ |
| 1963 |
public: |
| 1964 |
QPropertySpec(const TypeEntry *type) |
| 1965 |
: m_type(type), |
| 1966 |
m_index(-1) |
| 1967 |
{} |
| 1968 |
|
| 1969 |
const TypeEntry *type() const |
| 1970 |
{ |
| 1971 |
return m_type; |
| 1972 |
} |
| 1973 |
|
| 1974 |
QString name() const |
| 1975 |
{ |
| 1976 |
return m_name; |
| 1977 |
} |
| 1978 |
|
| 1979 |
void setName(const QString &name) |
| 1980 |
{ |
| 1981 |
m_name = name; |
| 1982 |
} |
| 1983 |
|
| 1984 |
QString read() const |
| 1985 |
{ |
| 1986 |
return m_read; |
| 1987 |
} |
| 1988 |
|
| 1989 |
void setRead(const QString &read) |
| 1990 |
{ |
| 1991 |
m_read = read; |
| 1992 |
} |
| 1993 |
|
| 1994 |
QString write() const |
| 1995 |
{ |
| 1996 |
return m_write; |
| 1997 |
} |
| 1998 |
|
| 1999 |
void setWrite(const QString &write) |
| 2000 |
{ |
| 2001 |
m_write = write; |
| 2002 |
} |
| 2003 |
|
| 2004 |
QString designable() const |
| 2005 |
{ |
| 2006 |
return m_designable; |
| 2007 |
} |
| 2008 |
|
| 2009 |
void setDesignable(const QString &designable) |
| 2010 |
{ |
| 2011 |
m_designable = designable; |
| 2012 |
} |
| 2013 |
|
| 2014 |
QString reset() const |
| 2015 |
{ |
| 2016 |
return m_reset; |
| 2017 |
} |
| 2018 |
|
| 2019 |
void setReset(const QString &reset) |
| 2020 |
{ |
| 2021 |
m_reset = reset; |
| 2022 |
} |
| 2023 |
|
| 2024 |
int index() const |
| 2025 |
{ |
| 2026 |
return m_index; |
| 2027 |
} |
| 2028 |
|
| 2029 |
void setIndex(int index) |
| 2030 |
{ |
| 2031 |
m_index = index; |
| 2032 |
} |
| 2033 |
|
| 2034 |
private: |
| 2035 |
QString m_name; |
| 2036 |
QString m_read; |
| 2037 |
QString m_write; |
| 2038 |
QString m_designable; |
| 2039 |
QString m_reset; |
| 2040 |
const TypeEntry *m_type; |
| 2041 |
int m_index; |
| 2042 |
}; |
| 2043 |
|
| 2044 |
inline AbstractMetaFunctionList AbstractMetaClass::allVirtualFunctions() const |
| 2045 |
{ |
| 2046 |
return queryFunctions(VirtualFunctions | NotRemovedFromTargetLang); |
| 2047 |
} |
| 2048 |
|
| 2049 |
inline AbstractMetaFunctionList AbstractMetaClass::allFinalFunctions() const |
| 2050 |
{ |
| 2051 |
return queryFunctions(FinalInTargetLangFunctions |
| 2052 |
| FinalInCppFunctions |
| 2053 |
| NotRemovedFromTargetLang); |
| 2054 |
} |
| 2055 |
|
| 2056 |
inline AbstractMetaFunctionList AbstractMetaClass::cppInconsistentFunctions() const |
| 2057 |
{ |
| 2058 |
return queryFunctions(Inconsistent |
| 2059 |
| NormalFunctions |
| 2060 |
| Visible |
| 2061 |
| NotRemovedFromTargetLang); |
| 2062 |
} |
| 2063 |
|
| 2064 |
inline AbstractMetaFunctionList AbstractMetaClass::cppSignalFunctions() const |
| 2065 |
{ |
| 2066 |
return queryFunctions(Signals |
| 2067 |
| Visible |
| 2068 |
| NotRemovedFromTargetLang); |
| 2069 |
} |
| 2070 |
|
| 2071 |
#endif // ABSTRACTMETALANG_H |