49fc29592d46471d020a55f52630cf0a89b04af2
[profile/ivi/qtbase.git] / src / tools / moc / moc.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "moc.h"
43 #include "generator.h"
44 #include "qdatetime.h"
45 #include "utils.h"
46 #include "outputrevision.h"
47 #include <QtCore/qfile.h>
48 #include <QtCore/qfileinfo.h>
49 #include <QtCore/qdir.h>
50
51 // for normalizeTypeInternal
52 #include <private/qmetaobject_moc_p.h>
53
54 QT_BEGIN_NAMESPACE
55
56 // only moc needs this function
57 static QByteArray normalizeType(const QByteArray &ba, bool fixScope = false)
58 {
59     const char *s = ba.constData();
60     int len = ba.size();
61     char stackbuf[64];
62     char *buf = (len >= 64 ? new char[len + 1] : stackbuf);
63     char *d = buf;
64     char last = 0;
65     while(*s && is_space(*s))
66         s++;
67     while (*s) {
68         while (*s && !is_space(*s))
69             last = *d++ = *s++;
70         while (*s && is_space(*s))
71             s++;
72         if (*s && ((is_ident_char(*s) && is_ident_char(last))
73                    || ((*s == ':') && (last == '<')))) {
74             last = *d++ = ' ';
75         }
76     }
77     *d = '\0';
78     QByteArray result;
79     if (strncmp("void", buf, d - buf) != 0)
80         result = normalizeTypeInternal(buf, d, fixScope);
81     if (buf != stackbuf)
82         delete [] buf;
83     return result;
84 }
85
86 bool Moc::parseClassHead(ClassDef *def)
87 {
88     // figure out whether this is a class declaration, or only a
89     // forward or variable declaration.
90     int i = 0;
91     Token token;
92     do {
93         token = lookup(i++);
94         if (token == COLON || token == LBRACE)
95             break;
96         if (token == SEMIC || token == RANGLE)
97             return false;
98     } while (token);
99
100     if (!test(IDENTIFIER)) // typedef struct { ... }
101         return false;
102     QByteArray name = lexem();
103
104     // support "class IDENT name" and "class IDENT(IDENT) name"
105     if (test(LPAREN)) {
106         until(RPAREN);
107         if (!test(IDENTIFIER))
108             return false;
109         name = lexem();
110     } else  if (test(IDENTIFIER)) {
111         name = lexem();
112     }
113
114     def->qualified += name;
115     while (test(SCOPE)) {
116         def->qualified += lexem();
117         if (test(IDENTIFIER)) {
118             name = lexem();
119             def->qualified += name;
120         }
121     }
122     def->classname = name;
123     if (test(COLON)) {
124         do {
125             test(VIRTUAL);
126             FunctionDef::Access access = FunctionDef::Public;
127             if (test(PRIVATE))
128                 access = FunctionDef::Private;
129             else if (test(PROTECTED))
130                 access = FunctionDef::Protected;
131             else
132                 test(PUBLIC);
133             test(VIRTUAL);
134             const QByteArray type = parseType().name;
135             // ignore the 'class Foo : BAR(Baz)' case
136             if (test(LPAREN)) {
137                 until(RPAREN);
138             } else {
139                 def->superclassList += qMakePair(type, access);
140             }
141         } while (test(COMMA));
142     }
143     if (!test(LBRACE))
144         return false;
145     def->begin = index - 1;
146     bool foundRBrace = until(RBRACE);
147     def->end = index;
148     index = def->begin + 1;
149     return foundRBrace;
150 }
151
152 Type Moc::parseType()
153 {
154     Type type;
155     bool hasSignedOrUnsigned = false;
156     bool isVoid = false;
157     type.firstToken = lookup();
158     for (;;) {
159         switch (next()) {
160             case SIGNED:
161             case UNSIGNED:
162                 hasSignedOrUnsigned = true;
163                 // fall through
164             case CONST:
165             case VOLATILE:
166                 type.name += lexem();
167                 type.name += ' ';
168                 if (lookup(0) == VOLATILE)
169                     type.isVolatile = true;
170                 continue;
171             case Q_MOC_COMPAT_TOKEN:
172             case Q_INVOKABLE_TOKEN:
173             case Q_SCRIPTABLE_TOKEN:
174             case Q_SIGNALS_TOKEN:
175             case Q_SLOTS_TOKEN:
176             case Q_SIGNAL_TOKEN:
177             case Q_SLOT_TOKEN:
178                 type.name += lexem();
179                 return type;
180             default:
181                 prev();
182                 break;
183         }
184         break;
185     }
186     test(ENUM) || test(CLASS) || test(STRUCT);
187     for(;;) {
188         switch (next()) {
189         case IDENTIFIER:
190             // void mySlot(unsigned myArg)
191             if (hasSignedOrUnsigned) {
192                 prev();
193                 break;
194             }
195         case CHAR:
196         case SHORT:
197         case INT:
198         case LONG:
199             type.name += lexem();
200             // preserve '[unsigned] long long', 'short int', 'long int', 'long double'
201             if (test(LONG) || test(INT) || test(DOUBLE)) {
202                 type.name += ' ';
203                 prev();
204                 continue;
205             }
206             break;
207         case FLOAT:
208         case DOUBLE:
209         case VOID:
210         case BOOL:
211             type.name += lexem();
212             isVoid |= (lookup(0) == VOID);
213             break;
214         default:
215             prev();
216             ;
217         }
218         if (test(LANGLE)) {
219             QByteArray templ = lexemUntil(RANGLE);
220             for (int i = 0; i < templ.size(); ++i) {
221                 type.name += templ.at(i);
222                 if ((templ.at(i) == '<' && i+1 < templ.size() && templ.at(i+1) == ':')
223                     || (templ.at(i) == '>' && i+1 < templ.size() && templ.at(i+1) == '>')) {
224                     type.name += ' ';
225                 }
226             }
227         }
228         if (test(SCOPE)) {
229             type.name += lexem();
230             type.isScoped = true;
231         } else {
232             break;
233         }
234     }
235     while (test(CONST) || test(VOLATILE) || test(SIGNED) || test(UNSIGNED)
236            || test(STAR) || test(AND) || test(ANDAND)) {
237         type.name += ' ';
238         type.name += lexem();
239         if (lookup(0) == AND)
240             type.referenceType = Type::Reference;
241         else if (lookup(0) == ANDAND)
242             type.referenceType = Type::RValueReference;
243         else if (lookup(0) == STAR)
244             type.referenceType = Type::Pointer;
245     }
246     type.rawName = type.name;
247     // transform stupid things like 'const void' or 'void const' into 'void'
248     if (isVoid && type.referenceType == Type::NoReference) {
249         type.name = "void";
250     }
251     return type;
252 }
253
254 bool Moc::parseEnum(EnumDef *def)
255 {
256     bool isTypdefEnum = false; // typedef enum { ... } Foo;
257
258     if (test(CLASS))
259         def->isEnumClass = true;
260
261     if (test(IDENTIFIER)) {
262         def->name = lexem();
263     } else {
264         if (lookup(-1) != TYPEDEF)
265             return false; // anonymous enum
266         isTypdefEnum = true;
267     }
268     if (test(COLON)) { // C++11 strongly typed enum
269         // enum Foo : unsigned long { ... };
270         parseType(); //ignore the result
271     }
272     if (!test(LBRACE))
273         return false;
274     do {
275         if (lookup() == RBRACE) // accept trailing comma
276             break;
277         next(IDENTIFIER);
278         def->values += lexem();
279     } while (test(EQ) ? until(COMMA) : test(COMMA));
280     next(RBRACE);
281     if (isTypdefEnum) {
282         if (!test(IDENTIFIER))
283             return false;
284         def->name = lexem();
285     }
286     return true;
287 }
288
289 void Moc::parseFunctionArguments(FunctionDef *def)
290 {
291     Q_UNUSED(def);
292     while (hasNext()) {
293         ArgumentDef  arg;
294         arg.type = parseType();
295         if (arg.type.name == "void")
296             break;
297         if (test(IDENTIFIER))
298             arg.name = lexem();
299         while (test(LBRACK)) {
300             arg.rightType += lexemUntil(RBRACK);
301         }
302         if (test(CONST) || test(VOLATILE)) {
303             arg.rightType += ' ';
304             arg.rightType += lexem();
305         }
306         arg.normalizedType = normalizeType(QByteArray(arg.type.name + ' ' + arg.rightType));
307         arg.typeNameForCast = normalizeType(QByteArray(noRef(arg.type.name) + "(*)" + arg.rightType));
308         if (test(EQ))
309             arg.isDefault = true;
310         def->arguments += arg;
311         if (!until(COMMA))
312             break;
313     }
314 }
315
316 bool Moc::testFunctionAttribute(FunctionDef *def)
317 {
318     if (index < symbols.size() && testFunctionAttribute(symbols.at(index).token, def)) {
319         ++index;
320         return true;
321     }
322     return false;
323 }
324
325 bool Moc::testFunctionAttribute(Token tok, FunctionDef *def)
326 {
327     switch (tok) {
328         case Q_MOC_COMPAT_TOKEN:
329             def->isCompat = true;
330             return true;
331         case Q_INVOKABLE_TOKEN:
332             def->isInvokable = true;
333             return true;
334         case Q_SIGNAL_TOKEN:
335             def->isSignal = true;
336             return true;
337         case Q_SLOT_TOKEN:
338             def->isSlot = true;
339             return true;
340         case Q_SCRIPTABLE_TOKEN:
341             def->isInvokable = def->isScriptable = true;
342             return true;
343         default: break;
344     }
345     return false;
346 }
347
348 bool Moc::testFunctionRevision(FunctionDef *def)
349 {
350     if (test(Q_REVISION_TOKEN)) {
351         next(LPAREN);
352         QByteArray revision = lexemUntil(RPAREN);
353         revision.remove(0, 1);
354         revision.chop(1);
355         bool ok = false;
356         def->revision = revision.toInt(&ok);
357         if (!ok || def->revision < 0)
358             error("Invalid revision");
359         return true;
360     }
361
362     return false;
363 }
364
365 // returns false if the function should be ignored
366 bool Moc::parseFunction(FunctionDef *def, bool inMacro)
367 {
368     def->isVirtual = false;
369     def->isStatic = false;
370     //skip modifiers and attributes
371     while (test(INLINE) || (test(STATIC) && (def->isStatic = true)) ||
372         (test(VIRTUAL) && (def->isVirtual = true)) //mark as virtual
373         || testFunctionAttribute(def) || testFunctionRevision(def)) {}
374     bool templateFunction = (lookup() == TEMPLATE);
375     def->type = parseType();
376     if (def->type.name.isEmpty()) {
377         if (templateFunction)
378             error("Template function as signal or slot");
379         else
380             error();
381     }
382     bool scopedFunctionName = false;
383     if (test(LPAREN)) {
384         def->name = def->type.name;
385         scopedFunctionName = def->type.isScoped;
386         def->type = Type("int");
387     } else {
388         Type tempType = parseType();;
389         while (!tempType.name.isEmpty() && lookup() != LPAREN) {
390             if (testFunctionAttribute(def->type.firstToken, def))
391                 ; // fine
392             else if (def->type.firstToken == Q_SIGNALS_TOKEN)
393                 error();
394             else if (def->type.firstToken == Q_SLOTS_TOKEN)
395                 error();
396             else {
397                 if (!def->tag.isEmpty())
398                     def->tag += ' ';
399                 def->tag += def->type.name;
400             }
401             def->type = tempType;
402             tempType = parseType();
403         }
404         next(LPAREN, "Not a signal or slot declaration");
405         def->name = tempType.name;
406         scopedFunctionName = tempType.isScoped;
407     }
408
409     // we don't support references as return types, it's too dangerous
410     if (def->type.referenceType == Type::Reference) {
411         QByteArray rawName = def->type.rawName;
412         def->type = Type("void");
413         def->type.rawName = rawName;
414     }
415
416     def->normalizedType = normalizeType(def->type.name);
417
418     if (!test(RPAREN)) {
419         parseFunctionArguments(def);
420         next(RPAREN);
421     }
422
423     // support optional macros with compiler specific options
424     while (test(IDENTIFIER))
425         ;
426
427     def->isConst = test(CONST);
428
429     while (test(IDENTIFIER))
430         ;
431
432     if (inMacro) {
433         next(RPAREN);
434         prev();
435     } else {
436         if (test(THROW)) {
437             next(LPAREN);
438             until(RPAREN);
439         }
440         if (test(SEMIC))
441             ;
442         else if ((def->inlineCode = test(LBRACE)))
443             until(RBRACE);
444         else if ((def->isAbstract = test(EQ)))
445             until(SEMIC);
446         else
447             error();
448     }
449
450     if (scopedFunctionName) {
451         QByteArray msg("Function declaration ");
452         msg += def->name;
453         msg += " contains extra qualification. Ignoring as signal or slot.";
454         warning(msg.constData());
455         return false;
456     }
457     return true;
458 }
459
460 // like parseFunction, but never aborts with an error
461 bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
462 {
463     def->isVirtual = false;
464     def->isStatic = false;
465     //skip modifiers and attributes
466     while (test(EXPLICIT) || test(INLINE) || (test(STATIC) && (def->isStatic = true)) ||
467         (test(VIRTUAL) && (def->isVirtual = true)) //mark as virtual
468         || testFunctionAttribute(def) || testFunctionRevision(def)) {}
469     bool tilde = test(TILDE);
470     def->type = parseType();
471     if (def->type.name.isEmpty())
472         return false;
473     bool scopedFunctionName = false;
474     if (test(LPAREN)) {
475         def->name = def->type.name;
476         scopedFunctionName = def->type.isScoped;
477         if (def->name == cdef->classname) {
478             def->isDestructor = tilde;
479             def->isConstructor = !tilde;
480             def->type = Type();
481         } else {
482             def->type = Type("int");
483         }
484     } else {
485         Type tempType = parseType();;
486         while (!tempType.name.isEmpty() && lookup() != LPAREN) {
487             if (testFunctionAttribute(def->type.firstToken, def))
488                 ; // fine
489             else if (def->type.name == "Q_SIGNAL")
490                 def->isSignal = true;
491             else if (def->type.name == "Q_SLOT")
492                 def->isSlot = true;
493             else {
494                 if (!def->tag.isEmpty())
495                     def->tag += ' ';
496                 def->tag += def->type.name;
497             }
498             def->type = tempType;
499             tempType = parseType();
500         }
501         if (!test(LPAREN))
502             return false;
503         def->name = tempType.name;
504         scopedFunctionName = tempType.isScoped;
505     }
506
507     // we don't support references as return types, it's too dangerous
508     if (def->type.referenceType == Type::Reference) {
509         QByteArray rawName = def->type.rawName;
510         def->type = Type("void");
511         def->type.rawName = rawName;
512     }
513
514     def->normalizedType = normalizeType(def->type.name);
515
516     if (!test(RPAREN)) {
517         parseFunctionArguments(def);
518         if (!test(RPAREN))
519             return false;
520     }
521     def->isConst = test(CONST);
522     if (scopedFunctionName
523         && (def->isSignal || def->isSlot || def->isInvokable)) {
524         QByteArray msg("parsemaybe: Function declaration ");
525         msg += def->name;
526         msg += " contains extra qualification. Ignoring as signal or slot.";
527         warning(msg.constData());
528         return false;
529     }
530     return true;
531 }
532
533
534 void Moc::parse()
535 {
536     QList<NamespaceDef> namespaceList;
537     bool templateClass = false;
538     while (hasNext()) {
539         Token t = next();
540         switch (t) {
541             case NAMESPACE: {
542                 int rewind = index;
543                 if (test(IDENTIFIER)) {
544                     if (test(EQ)) {
545                         // namespace Foo = Bar::Baz;
546                         until(SEMIC);
547                     } else if (!test(SEMIC)) {
548                         NamespaceDef def;
549                         def.name = lexem();
550                         next(LBRACE);
551                         def.begin = index - 1;
552                         until(RBRACE);
553                         def.end = index;
554                         index = def.begin + 1;
555                         namespaceList += def;
556                         index = rewind;
557                     }
558                 }
559                 break;
560             }
561             case SEMIC:
562             case RBRACE:
563                 templateClass = false;
564                 break;
565             case TEMPLATE:
566                 templateClass = true;
567                 break;
568             case MOC_INCLUDE_BEGIN:
569                 currentFilenames.push(symbol().unquotedLexem());
570                 break;
571             case MOC_INCLUDE_END:
572                 currentFilenames.pop();
573                 break;
574             case Q_DECLARE_INTERFACE_TOKEN:
575                 parseDeclareInterface();
576                 break;
577             case Q_DECLARE_METATYPE_TOKEN:
578                 parseDeclareMetatype();
579                 break;
580             case USING:
581                 if (test(NAMESPACE)) {
582                     while (test(SCOPE) || test(IDENTIFIER))
583                         ;
584                     next(SEMIC);
585                 }
586                 break;
587             case CLASS:
588             case STRUCT: {
589                 if (currentFilenames.size() <= 1)
590                     break;
591
592                 ClassDef def;
593                 if (!parseClassHead(&def))
594                     continue;
595
596                 while (inClass(&def) && hasNext()) {
597                     if (next() == Q_OBJECT_TOKEN) {
598                         def.hasQObject = true;
599                         break;
600                     }
601                 }
602
603                 if (!def.hasQObject)
604                     continue;
605
606                 for (int i = namespaceList.size() - 1; i >= 0; --i)
607                     if (inNamespace(&namespaceList.at(i)))
608                         def.qualified.prepend(namespaceList.at(i).name + "::");
609
610                 knownQObjectClasses.insert(def.classname);
611                 knownQObjectClasses.insert(def.qualified);
612
613                 continue; }
614             default: break;
615         }
616         if ((t != CLASS && t != STRUCT)|| currentFilenames.size() > 1)
617             continue;
618         ClassDef def;
619         if (parseClassHead(&def)) {
620             FunctionDef::Access access = FunctionDef::Private;
621             for (int i = namespaceList.size() - 1; i >= 0; --i)
622                 if (inNamespace(&namespaceList.at(i)))
623                     def.qualified.prepend(namespaceList.at(i).name + "::");
624             while (inClass(&def) && hasNext()) {
625                 switch ((t = next())) {
626                 case PRIVATE:
627                     access = FunctionDef::Private;
628                     if (test(Q_SIGNALS_TOKEN))
629                         error("Signals cannot have access specifier");
630                     break;
631                 case PROTECTED:
632                     access = FunctionDef::Protected;
633                     if (test(Q_SIGNALS_TOKEN))
634                         error("Signals cannot have access specifier");
635                     break;
636                 case PUBLIC:
637                     access = FunctionDef::Public;
638                     if (test(Q_SIGNALS_TOKEN))
639                         error("Signals cannot have access specifier");
640                     break;
641                 case CLASS: {
642                     ClassDef nestedDef;
643                     if (parseClassHead(&nestedDef)) {
644                         while (inClass(&nestedDef) && inClass(&def)) {
645                             t = next();
646                             if (t >= Q_META_TOKEN_BEGIN && t < Q_META_TOKEN_END)
647                                 error("Meta object features not supported for nested classes");
648                         }
649                     }
650                 } break;
651                 case Q_SIGNALS_TOKEN:
652                     parseSignals(&def);
653                     break;
654                 case Q_SLOTS_TOKEN:
655                     switch (lookup(-1)) {
656                     case PUBLIC:
657                     case PROTECTED:
658                     case PRIVATE:
659                         parseSlots(&def, access);
660                         break;
661                     default:
662                         error("Missing access specifier for slots");
663                     }
664                     break;
665                 case Q_OBJECT_TOKEN:
666                     def.hasQObject = true;
667                     if (templateClass)
668                         error("Template classes not supported by Q_OBJECT");
669                     if (def.classname != "Qt" && def.classname != "QObject" && def.superclassList.isEmpty())
670                         error("Class contains Q_OBJECT macro but does not inherit from QObject");
671                     break;
672                 case Q_GADGET_TOKEN:
673                     def.hasQGadget = true;
674                     if (templateClass)
675                         error("Template classes not supported by Q_GADGET");
676                     break;
677                 case Q_PROPERTY_TOKEN:
678                     parseProperty(&def);
679                     break;
680                 case Q_PLUGIN_METADATA_TOKEN:
681                     parsePluginData(&def);
682                     break;
683                 case Q_ENUMS_TOKEN:
684                     parseEnumOrFlag(&def, false);
685                     break;
686                 case Q_FLAGS_TOKEN:
687                     parseEnumOrFlag(&def, true);
688                     break;
689                 case Q_DECLARE_FLAGS_TOKEN:
690                     parseFlag(&def);
691                     break;
692                 case Q_CLASSINFO_TOKEN:
693                     parseClassInfo(&def);
694                     break;
695                 case Q_INTERFACES_TOKEN:
696                     parseInterfaces(&def);
697                     break;
698                 case Q_PRIVATE_SLOT_TOKEN:
699                     parseSlotInPrivate(&def, access);
700                     break;
701                 case Q_PRIVATE_PROPERTY_TOKEN:
702                     parsePrivateProperty(&def);
703                     break;
704                 case ENUM: {
705                     EnumDef enumDef;
706                     if (parseEnum(&enumDef))
707                         def.enumList += enumDef;
708                 } break;
709                 case SEMIC:
710                 case COLON:
711                     break;
712                 default:
713                     FunctionDef funcDef;
714                     funcDef.access = access;
715                     int rewind = index--;
716                     if (parseMaybeFunction(&def, &funcDef)) {
717                         if (funcDef.isConstructor) {
718                             if ((access == FunctionDef::Public) && funcDef.isInvokable) {
719                                 def.constructorList += funcDef;
720                                 while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
721                                     funcDef.wasCloned = true;
722                                     funcDef.arguments.removeLast();
723                                     def.constructorList += funcDef;
724                                 }
725                             }
726                         } else if (funcDef.isDestructor) {
727                             // don't care about destructors
728                         } else {
729                             if (access == FunctionDef::Public)
730                                 def.publicList += funcDef;
731                             if (funcDef.isSlot) {
732                                 def.slotList += funcDef;
733                                 while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
734                                     funcDef.wasCloned = true;
735                                     funcDef.arguments.removeLast();
736                                     def.slotList += funcDef;
737                                 }
738                                 if (funcDef.revision > 0)
739                                     ++def.revisionedMethods;
740                             } else if (funcDef.isSignal) {
741                                 def.signalList += funcDef;
742                                 while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
743                                     funcDef.wasCloned = true;
744                                     funcDef.arguments.removeLast();
745                                     def.signalList += funcDef;
746                                 }
747                                 if (funcDef.revision > 0)
748                                     ++def.revisionedMethods;
749                             } else if (funcDef.isInvokable) {
750                                 def.methodList += funcDef;
751                                 while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
752                                     funcDef.wasCloned = true;
753                                     funcDef.arguments.removeLast();
754                                     def.methodList += funcDef;
755                                 }
756                                 if (funcDef.revision > 0)
757                                     ++def.revisionedMethods;
758                             }
759                         }
760                     } else {
761                         index = rewind;
762                     }
763                 }
764             }
765
766             next(RBRACE);
767
768             if (!def.hasQObject && !def.hasQGadget && def.signalList.isEmpty() && def.slotList.isEmpty()
769                 && def.propertyList.isEmpty() && def.enumDeclarations.isEmpty())
770                 continue; // no meta object code required
771
772
773             if (!def.hasQObject && !def.hasQGadget)
774                 error("Class declarations lacks Q_OBJECT macro.");
775
776             checkSuperClasses(&def);
777             checkProperties(&def);
778
779             classList += def;
780             knownQObjectClasses.insert(def.classname);
781             knownQObjectClasses.insert(def.qualified);
782         }
783     }
784 }
785
786 void Moc::generate(FILE *out)
787 {
788
789     QDateTime dt = QDateTime::currentDateTime();
790     QByteArray dstr = dt.toString().toLatin1();
791     QByteArray fn = filename;
792     int i = filename.length()-1;
793     while (i>0 && filename[i-1] != '/' && filename[i-1] != '\\')
794         --i;                                // skip path
795     if (i >= 0)
796         fn = filename.mid(i);
797     fprintf(out, "/****************************************************************************\n"
798             "** Meta object code from reading C++ file '%s'\n**\n" , fn.constData());
799     fprintf(out, "** Created: %s\n"
800             "**      by: The Qt Meta Object Compiler version %d (Qt %s)\n**\n" , dstr.data(), mocOutputRevision, QT_VERSION_STR);
801     fprintf(out, "** WARNING! All changes made in this file will be lost!\n"
802             "*****************************************************************************/\n\n");
803
804
805     if (!noInclude) {
806         if (includePath.size() && !includePath.endsWith('/'))
807             includePath += '/';
808         for (int i = 0; i < includeFiles.size(); ++i) {
809             QByteArray inc = includeFiles.at(i);
810             if (inc[0] != '<' && inc[0] != '"') {
811                 if (includePath.size() && includePath != "./")
812                     inc.prepend(includePath);
813                 inc = '\"' + inc + '\"';
814             }
815             fprintf(out, "#include %s\n", inc.constData());
816         }
817     }
818     if (classList.size() && classList.first().classname == "Qt")
819         fprintf(out, "#include <QtCore/qobject.h>\n");
820
821     fprintf(out, "#include <QtCore/qbytearray.h>\n"); // For QByteArrayData
822     fprintf(out, "#include <QtCore/qmetatype.h>\n");  // For QMetaType::Type
823     if (mustIncludeQPluginH)
824         fprintf(out, "#include <QtCore/qplugin.h>\n");
825
826     fprintf(out, "#if !defined(Q_MOC_OUTPUT_REVISION)\n"
827             "#error \"The header file '%s' doesn't include <QObject>.\"\n", fn.constData());
828     fprintf(out, "#elif Q_MOC_OUTPUT_REVISION != %d\n", mocOutputRevision);
829     fprintf(out, "#error \"This file was generated using the moc from %s."
830             " It\"\n#error \"cannot be used with the include files from"
831             " this version of Qt.\"\n#error \"(The moc has changed too"
832             " much.)\"\n", QT_VERSION_STR);
833     fprintf(out, "#endif\n\n");
834
835     fprintf(out, "QT_BEGIN_MOC_NAMESPACE\n");
836
837     for (i = 0; i < classList.size(); ++i) {
838         Generator generator(&classList[i], metaTypes, out);
839         generator.generateCode();
840     }
841
842     fprintf(out, "QT_END_MOC_NAMESPACE\n");
843 }
844
845 void Moc::parseSlots(ClassDef *def, FunctionDef::Access access)
846 {
847     int defaultRevision = -1;
848     if (test(Q_REVISION_TOKEN)) {
849         next(LPAREN);
850         QByteArray revision = lexemUntil(RPAREN);
851         revision.remove(0, 1);
852         revision.chop(1);
853         bool ok = false;
854         defaultRevision = revision.toInt(&ok);
855         if (!ok || defaultRevision < 0)
856             error("Invalid revision");
857     }
858
859     next(COLON);
860     while (inClass(def) && hasNext()) {
861         switch (next()) {
862         case PUBLIC:
863         case PROTECTED:
864         case PRIVATE:
865         case Q_SIGNALS_TOKEN:
866         case Q_SLOTS_TOKEN:
867             prev();
868             return;
869         case SEMIC:
870             continue;
871         case FRIEND:
872             until(SEMIC);
873             continue;
874         case USING:
875             error("'using' directive not supported in 'slots' section");
876         default:
877             prev();
878         }
879
880         FunctionDef funcDef;
881         funcDef.access = access;
882         if (!parseFunction(&funcDef))
883             continue;
884         if (funcDef.revision > 0) {
885             ++def->revisionedMethods;
886         } else if (defaultRevision != -1) {
887             funcDef.revision = defaultRevision;
888             ++def->revisionedMethods;
889         }
890         def->slotList += funcDef;
891         while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
892             funcDef.wasCloned = true;
893             funcDef.arguments.removeLast();
894             def->slotList += funcDef;
895         }
896     }
897 }
898
899 void Moc::parseSignals(ClassDef *def)
900 {
901     int defaultRevision = -1;
902     if (test(Q_REVISION_TOKEN)) {
903         next(LPAREN);
904         QByteArray revision = lexemUntil(RPAREN);
905         revision.remove(0, 1);
906         revision.chop(1);
907         bool ok = false;
908         defaultRevision = revision.toInt(&ok);
909         if (!ok || defaultRevision < 0)
910             error("Invalid revision");
911     }
912
913     next(COLON);
914     while (inClass(def) && hasNext()) {
915         switch (next()) {
916         case PUBLIC:
917         case PROTECTED:
918         case PRIVATE:
919         case Q_SIGNALS_TOKEN:
920         case Q_SLOTS_TOKEN:
921             prev();
922             return;
923         case SEMIC:
924             continue;
925         case FRIEND:
926             until(SEMIC);
927             continue;
928         case USING:
929             error("'using' directive not supported in 'signals' section");
930         default:
931             prev();
932         }
933         FunctionDef funcDef;
934         funcDef.access = FunctionDef::Protected;
935         parseFunction(&funcDef);
936         if (funcDef.isVirtual)
937             warning("Signals cannot be declared virtual");
938         if (funcDef.inlineCode)
939             error("Not a signal declaration");
940         if (funcDef.revision > 0) {
941             ++def->revisionedMethods;
942         } else if (defaultRevision != -1) {
943             funcDef.revision = defaultRevision;
944             ++def->revisionedMethods;
945         }
946         def->signalList += funcDef;
947         while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
948             funcDef.wasCloned = true;
949             funcDef.arguments.removeLast();
950             def->signalList += funcDef;
951         }
952     }
953 }
954
955 void Moc::createPropertyDef(PropertyDef &propDef)
956 {
957     QByteArray type = parseType().name;
958     if (type.isEmpty())
959         error();
960     propDef.designable = propDef.scriptable = propDef.stored = "true";
961     propDef.user = "false";
962     /*
963       The Q_PROPERTY construct cannot contain any commas, since
964       commas separate macro arguments. We therefore expect users
965       to type "QMap" instead of "QMap<QString, QVariant>". For
966       coherence, we also expect the same for
967       QValueList<QVariant>, the other template class supported by
968       QVariant.
969     */
970     type = normalizeType(type);
971     if (type == "QMap")
972         type = "QMap<QString,QVariant>";
973     else if (type == "QValueList")
974         type = "QValueList<QVariant>";
975     else if (type == "LongLong")
976         type = "qlonglong";
977     else if (type == "ULongLong")
978         type = "qulonglong";
979
980     propDef.type = type;
981
982     next();
983     propDef.name = lexem();
984     while (test(IDENTIFIER)) {
985         QByteArray l = lexem();
986         if (l[0] == 'C' && l == "CONSTANT") {
987             propDef.constant = true;
988             continue;
989         } else if(l[0] == 'F' && l == "FINAL") {
990             propDef.final = true;
991             continue;
992         }
993
994         QByteArray v, v2;
995         if (test(LPAREN)) {
996             v = lexemUntil(RPAREN);
997         } else if (test(INTEGER_LITERAL)) {
998             v = lexem();
999             if (l != "REVISION")
1000                 error(1);
1001         } else {
1002             next(IDENTIFIER);
1003             v = lexem();
1004             if (test(LPAREN))
1005                 v2 = lexemUntil(RPAREN);
1006             else if (v != "true" && v != "false")
1007                 v2 = "()";
1008         }
1009         switch (l[0]) {
1010         case 'R':
1011             if (l == "READ")
1012                 propDef.read = v;
1013             else if (l == "RESET")
1014                 propDef.reset = v + v2;
1015             else if (l == "REVISION") {
1016                 bool ok = false;
1017                 propDef.revision = v.toInt(&ok);
1018                 if (!ok || propDef.revision < 0)
1019                     error(1);
1020             } else
1021                 error(2);
1022             break;
1023         case 'S':
1024             if (l == "SCRIPTABLE")
1025                 propDef.scriptable = v + v2;
1026             else if (l == "STORED")
1027                 propDef.stored = v + v2;
1028             else
1029                 error(2);
1030             break;
1031         case 'W': if (l != "WRITE") error(2);
1032             propDef.write = v;
1033             break;
1034         case 'D': if (l != "DESIGNABLE") error(2);
1035             propDef.designable = v + v2;
1036             break;
1037         case 'E': if (l != "EDITABLE") error(2);
1038             propDef.editable = v + v2;
1039             break;
1040         case 'N': if (l != "NOTIFY") error(2);
1041             propDef.notify = v;
1042             break;
1043         case 'U': if (l != "USER") error(2);
1044             propDef.user = v + v2;
1045             break;
1046         default:
1047             error(2);
1048         }
1049     }
1050     if (propDef.read.isNull()) {
1051         QByteArray msg;
1052         msg += "Property declaration ";
1053         msg += propDef.name;
1054         msg += " has no READ accessor function. The property will be invalid.";
1055         warning(msg.constData());
1056     }
1057     if (propDef.constant && !propDef.write.isNull()) {
1058         QByteArray msg;
1059         msg += "Property declaration ";
1060         msg += propDef.name;
1061         msg += " is both WRITEable and CONSTANT. CONSTANT will be ignored.";
1062         propDef.constant = false;
1063         warning(msg.constData());
1064     }
1065     if (propDef.constant && !propDef.notify.isNull()) {
1066         QByteArray msg;
1067         msg += "Property declaration ";
1068         msg += propDef.name;
1069         msg += " is both NOTIFYable and CONSTANT. CONSTANT will be ignored.";
1070         propDef.constant = false;
1071         warning(msg.constData());
1072     }
1073 }
1074
1075 void Moc::parseProperty(ClassDef *def)
1076 {
1077     next(LPAREN);
1078     PropertyDef propDef;
1079     createPropertyDef(propDef);
1080     next(RPAREN);
1081
1082
1083     if(!propDef.notify.isEmpty())
1084         def->notifyableProperties++;
1085     if (propDef.revision > 0)
1086         ++def->revisionedProperties;
1087     def->propertyList += propDef;
1088 }
1089
1090 void Moc::parsePluginData(ClassDef *def)
1091 {
1092     next(LPAREN);
1093     QByteArray metaData;
1094     while (test(IDENTIFIER)) {
1095         QByteArray l = lexem();
1096         if (l == "IID") {
1097             next(STRING_LITERAL);
1098             def->pluginData.iid = unquotedLexem();
1099         } else if (l == "FILE") {
1100             next(STRING_LITERAL);
1101             QByteArray metaDataFile = unquotedLexem();
1102             QFileInfo fi(QFileInfo(QString::fromLocal8Bit(currentFilenames.top().constData())).dir(), QString::fromLocal8Bit(metaDataFile.constData()));
1103             if (!fi.exists()) {
1104                 QByteArray msg;
1105                 msg += "Plugin Metadata file ";
1106                 msg += lexem();
1107                 msg += " does not exist. Declaration will be ignored";
1108                 warning(msg.constData());
1109                 return;
1110             }
1111             QFile file(fi.canonicalFilePath());
1112             file.open(QFile::ReadOnly);
1113             metaData = file.readAll();
1114         }
1115     }
1116
1117     if (!metaData.isEmpty()) {
1118         def->pluginData.metaData = QJsonDocument::fromJson(metaData);
1119         if (!def->pluginData.metaData.isObject()) {
1120             QByteArray msg;
1121             msg += "Plugin Metadata file ";
1122             msg += lexem();
1123             msg += " does not contain a valid JSON object. Declaration will be ignored";
1124             warning(msg.constData());
1125             def->pluginData.iid = QByteArray();
1126             return;
1127         }
1128     }
1129
1130     mustIncludeQPluginH = true;
1131     next(RPAREN);
1132 }
1133
1134 void Moc::parsePrivateProperty(ClassDef *def)
1135 {
1136     next(LPAREN);
1137     PropertyDef propDef;
1138     next(IDENTIFIER);
1139     propDef.inPrivateClass = lexem();
1140     while (test(SCOPE)) {
1141         propDef.inPrivateClass += lexem();
1142         next(IDENTIFIER);
1143         propDef.inPrivateClass += lexem();
1144     }
1145     // also allow void functions
1146     if (test(LPAREN)) {
1147         next(RPAREN);
1148         propDef.inPrivateClass += "()";
1149     }
1150
1151     next(COMMA);
1152
1153     createPropertyDef(propDef);
1154
1155     if(!propDef.notify.isEmpty())
1156         def->notifyableProperties++;
1157     if (propDef.revision > 0)
1158         ++def->revisionedProperties;
1159
1160     def->propertyList += propDef;
1161 }
1162
1163 void Moc::parseEnumOrFlag(ClassDef *def, bool isFlag)
1164 {
1165     next(LPAREN);
1166     QByteArray identifier;
1167     while (test(IDENTIFIER)) {
1168         identifier = lexem();
1169         while (test(SCOPE) && test(IDENTIFIER)) {
1170             identifier += "::";
1171             identifier += lexem();
1172         }
1173         def->enumDeclarations[identifier] = isFlag;
1174     }
1175     next(RPAREN);
1176 }
1177
1178 void Moc::parseFlag(ClassDef *def)
1179 {
1180     next(LPAREN);
1181     QByteArray flagName, enumName;
1182     while (test(IDENTIFIER)) {
1183         flagName = lexem();
1184         while (test(SCOPE) && test(IDENTIFIER)) {
1185             flagName += "::";
1186             flagName += lexem();
1187         }
1188     }
1189     next(COMMA);
1190     while (test(IDENTIFIER)) {
1191         enumName = lexem();
1192         while (test(SCOPE) && test(IDENTIFIER)) {
1193             enumName += "::";
1194             enumName += lexem();
1195         }
1196     }
1197
1198     def->flagAliases.insert(enumName, flagName);
1199     next(RPAREN);
1200 }
1201
1202 void Moc::parseClassInfo(ClassDef *def)
1203 {
1204     next(LPAREN);
1205     ClassInfoDef infoDef;
1206     next(STRING_LITERAL);
1207     infoDef.name = symbol().unquotedLexem();
1208     next(COMMA);
1209     if (test(STRING_LITERAL)) {
1210         infoDef.value = symbol().unquotedLexem();
1211     } else {
1212         // support Q_CLASSINFO("help", QT_TR_NOOP("blah"))
1213         next(IDENTIFIER);
1214         next(LPAREN);
1215         next(STRING_LITERAL);
1216         infoDef.value = symbol().unquotedLexem();
1217         next(RPAREN);
1218     }
1219     next(RPAREN);
1220     def->classInfoList += infoDef;
1221 }
1222
1223 void Moc::parseInterfaces(ClassDef *def)
1224 {
1225     next(LPAREN);
1226     while (test(IDENTIFIER)) {
1227         QList<ClassDef::Interface> iface;
1228         iface += ClassDef::Interface(lexem());
1229         while (test(SCOPE)) {
1230             iface.last().className += lexem();
1231             next(IDENTIFIER);
1232             iface.last().className += lexem();
1233         }
1234         while (test(COLON)) {
1235             next(IDENTIFIER);
1236             iface += ClassDef::Interface(lexem());
1237             while (test(SCOPE)) {
1238                 iface.last().className += lexem();
1239                 next(IDENTIFIER);
1240                 iface.last().className += lexem();
1241             }
1242         }
1243         // resolve from classnames to interface ids
1244         for (int i = 0; i < iface.count(); ++i) {
1245             const QByteArray iid = interface2IdMap.value(iface.at(i).className);
1246             if (iid.isEmpty())
1247                 error("Undefined interface");
1248
1249             iface[i].interfaceId = iid;
1250         }
1251         def->interfaceList += iface;
1252     }
1253     next(RPAREN);
1254 }
1255
1256 void Moc::parseDeclareInterface()
1257 {
1258     next(LPAREN);
1259     QByteArray interface;
1260     next(IDENTIFIER);
1261     interface += lexem();
1262     while (test(SCOPE)) {
1263         interface += lexem();
1264         next(IDENTIFIER);
1265         interface += lexem();
1266     }
1267     next(COMMA);
1268     QByteArray iid;
1269     if (test(STRING_LITERAL)) {
1270         iid = lexem();
1271     } else {
1272         next(IDENTIFIER);
1273         iid = lexem();
1274     }
1275     interface2IdMap.insert(interface, iid);
1276     next(RPAREN);
1277 }
1278
1279 void Moc::parseDeclareMetatype()
1280 {
1281     next(LPAREN);
1282     QByteArray typeName = lexemUntil(RPAREN);
1283     typeName.remove(0, 1);
1284     typeName.chop(1);
1285     metaTypes.append(typeName);
1286 }
1287
1288 void Moc::parseSlotInPrivate(ClassDef *def, FunctionDef::Access access)
1289 {
1290     next(LPAREN);
1291     FunctionDef funcDef;
1292     next(IDENTIFIER);
1293     funcDef.inPrivateClass = lexem();
1294     // also allow void functions
1295     if (test(LPAREN)) {
1296         next(RPAREN);
1297         funcDef.inPrivateClass += "()";
1298     }
1299     next(COMMA);
1300     funcDef.access = access;
1301     parseFunction(&funcDef, true);
1302     def->slotList += funcDef;
1303     while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
1304         funcDef.wasCloned = true;
1305         funcDef.arguments.removeLast();
1306         def->slotList += funcDef;
1307     }
1308     if (funcDef.revision > 0)
1309         ++def->revisionedMethods;
1310
1311 }
1312
1313 QByteArray Moc::lexemUntil(Token target)
1314 {
1315     int from = index;
1316     until(target);
1317     QByteArray s;
1318     while (from <= index) {
1319         QByteArray n = symbols.at(from++-1).lexem();
1320         if (s.size() && n.size()
1321             && is_ident_char(s.at(s.size()-1))
1322             && is_ident_char(n.at(0)))
1323             s += ' ';
1324         s += n;
1325     }
1326     return s;
1327 }
1328
1329 bool Moc::until(Token target) {
1330     int braceCount = 0;
1331     int brackCount = 0;
1332     int parenCount = 0;
1333     int angleCount = 0;
1334     if (index) {
1335         switch(symbols.at(index-1).token) {
1336         case LBRACE: ++braceCount; break;
1337         case LBRACK: ++brackCount; break;
1338         case LPAREN: ++parenCount; break;
1339         case LANGLE: ++angleCount; break;
1340         default: break;
1341         }
1342     }
1343
1344     //when searching commas within the default argument, we should take care of template depth (anglecount)
1345     // unfortunatelly, we do not have enough semantic information to know if '<' is the operator< or
1346     // the beginning of a template type. so we just use heuristics.
1347     int possible = -1;
1348
1349     while (index < symbols.size()) {
1350         Token t = symbols.at(index++).token;
1351         switch (t) {
1352         case LBRACE: ++braceCount; break;
1353         case RBRACE: --braceCount; break;
1354         case LBRACK: ++brackCount; break;
1355         case RBRACK: --brackCount; break;
1356         case LPAREN: ++parenCount; break;
1357         case RPAREN: --parenCount; break;
1358         case LANGLE: ++angleCount; break;
1359         case RANGLE: --angleCount; break;
1360         case GTGT: angleCount -= 2; t = RANGLE; break;
1361         default: break;
1362         }
1363         if (t == target
1364             && braceCount <= 0
1365             && brackCount <= 0
1366             && parenCount <= 0
1367             && (target != RANGLE || angleCount <= 0)) {
1368             if (target != COMMA || angleCount <= 0)
1369                 return true;
1370             possible = index;
1371         }
1372
1373         if (target == COMMA && t == EQ && possible != -1) {
1374             index = possible;
1375             return true;
1376         }
1377
1378         if (braceCount < 0 || brackCount < 0 || parenCount < 0
1379             || (target == RANGLE && angleCount < 0)) {
1380             --index;
1381             break;
1382         }
1383     }
1384
1385     if(target == COMMA && angleCount != 0 && possible != -1) {
1386         index = possible;
1387         return true;
1388     }
1389
1390     return false;
1391 }
1392
1393 void Moc::checkSuperClasses(ClassDef *def)
1394 {
1395     const QByteArray firstSuperclass = def->superclassList.value(0).first;
1396
1397     if (!knownQObjectClasses.contains(firstSuperclass)) {
1398         // enable once we /require/ include paths
1399 #if 0
1400         QByteArray msg;
1401         msg += "Class ";
1402         msg += def->className;
1403         msg += " contains the Q_OBJECT macro and inherits from ";
1404         msg += def->superclassList.value(0);
1405         msg += " but that is not a known QObject subclass. You may get compilation errors.";
1406         warning(msg.constData());
1407 #endif
1408         return;
1409     }
1410     for (int i = 1; i < def->superclassList.count(); ++i) {
1411         const QByteArray superClass = def->superclassList.at(i).first;
1412         if (knownQObjectClasses.contains(superClass)) {
1413             QByteArray msg;
1414             msg += "Class ";
1415             msg += def->classname;
1416             msg += " inherits from two QObject subclasses ";
1417             msg += firstSuperclass;
1418             msg += " and ";
1419             msg += superClass;
1420             msg += ". This is not supported!";
1421             warning(msg.constData());
1422         }
1423
1424         if (interface2IdMap.contains(superClass)) {
1425             bool registeredInterface = false;
1426             for (int i = 0; i < def->interfaceList.count(); ++i)
1427                 if (def->interfaceList.at(i).first().className == superClass) {
1428                     registeredInterface = true;
1429                     break;
1430                 }
1431
1432             if (!registeredInterface) {
1433                 QByteArray msg;
1434                 msg += "Class ";
1435                 msg += def->classname;
1436                 msg += " implements the interface ";
1437                 msg += superClass;
1438                 msg += " but does not list it in Q_INTERFACES. qobject_cast to ";
1439                 msg += superClass;
1440                 msg += " will not work!";
1441                 warning(msg.constData());
1442             }
1443         }
1444     }
1445 }
1446
1447 void Moc::checkProperties(ClassDef *cdef)
1448 {
1449     //
1450     // specify get function, for compatibiliy we accept functions
1451     // returning pointers, or const char * for QByteArray.
1452     //
1453     for (int i = 0; i < cdef->propertyList.count(); ++i) {
1454         PropertyDef &p = cdef->propertyList[i];
1455         if (p.read.isEmpty())
1456             continue;
1457         for (int j = 0; j < cdef->publicList.count(); ++j) {
1458             const FunctionDef &f = cdef->publicList.at(j);
1459             if (f.name != p.read)
1460                 continue;
1461             if (!f.isConst) // get  functions must be const
1462                 continue;
1463             if (f.arguments.size()) // and must not take any arguments
1464                 continue;
1465             PropertyDef::Specification spec = PropertyDef::ValueSpec;
1466             QByteArray tmp = f.normalizedType;
1467             if (p.type == "QByteArray" && tmp == "const char *")
1468                 tmp = "QByteArray";
1469             if (tmp.left(6) == "const ")
1470                 tmp = tmp.mid(6);
1471             if (p.type != tmp && tmp.endsWith('*')) {
1472                 tmp.chop(1);
1473                 spec = PropertyDef::PointerSpec;
1474             } else if (f.type.name.endsWith('&')) { // raw type, not normalized type
1475                 spec = PropertyDef::ReferenceSpec;
1476             }
1477             if (p.type != tmp)
1478                 continue;
1479             p.gspec = spec;
1480             break;
1481         }
1482         if(!p.notify.isEmpty()) {
1483             int notifyId = -1;
1484             for (int j = 0; j < cdef->signalList.count(); ++j) {
1485                 const FunctionDef &f = cdef->signalList.at(j);
1486                 if(f.name != p.notify) {
1487                     continue;
1488                 } else {
1489                     notifyId = j /* Signal indexes start from 0 */;
1490                     break;
1491                 }
1492             }
1493             p.notifyId = notifyId;
1494             if (notifyId == -1) {
1495                 QByteArray msg = "NOTIFY signal '" + p.notify + "' of property '" + p.name
1496                         + "' does not exist in class " + cdef->classname + ".";
1497                 error(msg.constData());
1498             }
1499         }
1500     }
1501 }
1502
1503
1504
1505 QT_END_NAMESPACE