source: trunk/src/moc/moc_yacc.cpp@ 9

Last change on this file since 9 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 148.9 KB
Line 
1#ifndef lint
2static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
3#endif
4#define YYBYACC 1
5#define YYMAJOR 1
6#define YYMINOR 9
7#define yyclearin (yychar=(-1))
8#define yyerrok (yyerrflag=0)
9#define YYRECOVERING (yyerrflag!=0)
10#define YYPREFIX "yy"
11#line 55 "moc.y"
12#define MOC_YACC_CODE
13void yyerror( const char *msg );
14
15#include "qplatformdefs.h"
16#include "qasciidict.h"
17#include "qdatetime.h"
18#include "qdict.h"
19#include "qfile.h"
20#include "qdir.h"
21#include "qptrlist.h"
22#include "qregexp.h"
23#include "qstrlist.h"
24#ifdef MOC_MWERKS_PLUGIN
25# ifdef Q_OS_MACX
26# undef OLD_DEBUG
27# ifdef DEBUG
28# define OLD_DEBUG DEBUG
29# undef DEBUG
30# endif
31# define DEBUG 0
32# ifndef __IMAGECAPTURE__
33# define __IMAGECAPTURE__
34# endif
35# include <Carbon/Carbon.h>
36# endif
37# include "mwerks_mac.h"
38#endif
39
40#include <ctype.h>
41#include <stdio.h>
42#include <stdlib.h>
43
44#if defined CONST
45#undef CONST
46#endif
47#if defined VOID
48#undef VOID
49#endif
50
51bool isEnumType( const char* type );
52int enumIndex( const char* type );
53bool isVariantType( const char* type );
54int qvariant_nameToType( const char* name );
55static void init(); /* initialize*/
56static void initClass(); /* prepare for new class*/
57static void generateClass(); /* generate C++ code for class*/
58static void initExpression(); /* prepare for new expression*/
59static void enterNameSpace( const char *name = 0 );
60static void leaveNameSpace();
61static void selectOutsideClassState();
62static void registerClassInNamespace();
63static bool suppress_func_warn = FALSE;
64static void func_warn( const char *msg );
65static void moc_warn( const char *msg );
66static void moc_err( const char *s );
67static void moc_err( const char *s1, const char *s2 );
68static void operatorError();
69static void checkPropertyName( const char* ident );
70
71static const char* const utype_map[] =
72{
73 "bool",
74 "int",
75 "double",
76 "QString",
77 "QVariant",
78 0
79};
80
81bool validUType( QCString ctype )
82{
83 if ( ctype.left(6) == "const " )
84 ctype = ctype.mid( 6, ctype.length() - 6 );
85 if ( ctype.right(1) == "&" )
86 ctype = ctype.left( ctype.length() - 1 );
87 else if ( ctype.right(1) == "*" )
88 return TRUE;
89
90 int i = -1;
91 while ( utype_map[++i] )
92 if ( ctype == utype_map[i] )
93 return TRUE;
94
95 return isEnumType( ctype );
96}
97
98QCString castToUType( QCString ctype )
99{
100 if ( ctype.right(1) == "&" )
101 ctype = ctype.left( ctype.length() - 1 );
102 if( ctype.right(1) == "]") {
103 int lb = ctype.findRev('[');
104 if(lb != -1)
105 ctype = ctype.left(lb) + "*";
106 }
107 return ctype;
108}
109
110QCString rawUType( QCString ctype )
111{
112 ctype = castToUType( ctype );
113 if ( ctype.left(6) == "const " )
114 ctype = ctype.mid( 6, ctype.length() - 6 );
115 return ctype;
116}
117
118QCString uType( QCString ctype )
119{
120 if ( !validUType( ctype ) ) {
121 if ( isVariantType( rawUType(ctype) ) )
122 return "varptr";
123 else
124 return "ptr";
125 }
126 if ( ctype.left(6) == "const " )
127 ctype = ctype.mid( 6, ctype.length() - 6 );
128 if ( ctype.right(1) == "&" ) {
129 ctype = ctype.left( ctype.length() - 1 );
130 } else if ( ctype.right(1) == "*" ) {
131 QCString raw = ctype.left( ctype.length() - 1 );
132 ctype = "ptr";
133 if ( raw == "char" )
134 ctype = "charstar";
135 else if ( raw == "QUnknownInterface" )
136 ctype = "iface";
137 else if ( raw == "QDispatchInterface" )
138 ctype = "idisp";
139 else if ( isVariantType( raw ) )
140 ctype = "varptr";
141 }
142 if ( isEnumType( ctype ) )
143 ctype = "enum";
144 return ctype;
145}
146
147bool isInOut( QCString ctype )
148{
149 if ( ctype.left(6) == "const " )
150 return FALSE;
151 if ( ctype.right(1) == "&" )
152 return TRUE;
153 if ( ctype.right(2) == "**" )
154 return TRUE;
155 return FALSE;
156}
157
158QCString uTypeExtra( QCString ctype )
159{
160 QCString typeExtra = "0";
161 if ( !validUType( ctype ) ) {
162 if ( isVariantType( rawUType(ctype) ) )
163 typeExtra.sprintf("\"\\x%02x\"", qvariant_nameToType( rawUType(ctype) ) );
164 else
165 typeExtra.sprintf( "\"%s\"", rawUType(ctype).data() );
166 return typeExtra;
167 }
168 if ( ctype.left(6) == "const " )
169 ctype = ctype.mid( 6, ctype.length() - 6 );
170 if ( ctype.right(1) == "&" )
171 ctype = ctype.left( ctype.length() - 1 );
172 if ( ctype.right(1) == "*" ) {
173 QCString raw = ctype.left( ctype.length() - 1 );
174 ctype = "ptr";
175 if ( raw == "char" )
176 ;
177 else if ( isVariantType( raw ) )
178 typeExtra.sprintf("\"\\x%02x\"", qvariant_nameToType( raw ) );
179 else
180 typeExtra.sprintf( "\"%s\"", raw.stripWhiteSpace().data() );
181
182 } else if ( isEnumType( ctype ) ) {
183 int idx = enumIndex( ctype );
184 if ( idx >= 0 ) {
185 typeExtra.sprintf( "&enum_tbl[%d]", enumIndex( ctype ) );
186 } else {
187 typeExtra.sprintf( "parentObject->enumerator(\"%s\", TRUE )", ctype.data() );
188 }
189 typeExtra =
190 "\n#ifndef QT_NO_PROPERTIES\n\t " + typeExtra +
191 "\n#else"
192 "\n\t 0"
193 "\n#endif // QT_NO_PROPERTIES\n\t ";
194 }
195 return typeExtra;
196}
197
198/*
199 Attention!
200 This table is copied from qvariant.cpp. If you change
201 one, change both.
202*/
203static const int ntypes = 35;
204static const char* const type_map[ntypes] =
205{
206 0,
207 "QMap<QString,QVariant>",
208 "QValueList<QVariant>",
209 "QString",
210 "QStringList",
211 "QFont",
212 "QPixmap",
213 "QBrush",
214 "QRect",
215 "QSize",
216 "QColor",
217 "QPalette",
218 "QColorGroup",
219 "QIconSet",
220 "QPoint",
221 "QImage",
222 "int",
223 "uint",
224 "bool",
225 "double",
226 "QCString",
227 "QPointArray",
228 "QRegion",
229 "QBitmap",
230 "QCursor",
231 "QSizePolicy",
232 "QDate",
233 "QTime",
234 "QDateTime",
235 "QByteArray",
236 "QBitArray",
237 "QKeySequence",
238 "QPen",
239 "Q_LLONG",
240 "Q_ULLONG"
241};
242
243int qvariant_nameToType( const char* name )
244{
245 for ( int i = 0; i < ntypes; i++ ) {
246 if ( !qstrcmp( type_map[i], name ) )
247 return i;
248 }
249 return 0;
250}
251
252/*
253 Returns TRUE if the type is a QVariant types.
254*/
255bool isVariantType( const char* type )
256{
257 return qvariant_nameToType( type ) != 0;
258}
259
260/*
261 Replaces '>>' with '> >' (as in 'QValueList<QValueList<double> >').
262 This function must be called to produce valid C++ code. However,
263 the string representation still uses '>>'.
264*/
265void fixRightAngles( QCString *str )
266{
267 str->replace( QRegExp(">>"), "> >" );
268}
269
270static QCString rmWS( const char * );
271
272enum Access { Private, Protected, Public };
273
274
275class Argument /* single arg meta data*/
276{
277public:
278 Argument( const char *left, const char *right, const char* argName = 0, bool isDefaultArgument = FALSE )
279 {
280 leftType = rmWS( left );
281 rightType = rmWS( right );
282 if ( leftType == "void" && rightType.isEmpty() )
283 leftType = "";
284
285 int len = leftType.length();
286
287 /*
288 Convert 'char const *' into 'const char *'. Start at index 1,
289 not 0, because 'const char *' is already OK.
290 */
291 for ( int i = 1; i < len; i++ ) {
292 if ( leftType[i] == 'c' &&
293 strncmp(leftType.data() + i + 1, "onst", 4) == 0 ) {
294 leftType.remove( i, 5 );
295 if ( leftType[i - 1] == ' ' )
296 leftType.remove( i - 1, 1 );
297 leftType.prepend( "const " );
298 break;
299 }
300
301 /*
302 We musn't convert 'char * const *' into 'const char **'
303 and we must beware of 'Bar<const Bla>'.
304 */
305 if ( leftType[i] == '&' || leftType[i] == '*' ||
306 leftType[i] == '<' )
307 break;
308 }
309
310 name = argName;
311 isDefault = isDefaultArgument;
312 }
313
314 QCString leftType;
315 QCString rightType;
316 QCString name;
317 bool isDefault;
318};
319
320class ArgList : public QPtrList<Argument> { /* member function arg list*/
321public:
322 ArgList() { setAutoDelete( TRUE ); }
323 ~ArgList() { clear(); }
324
325 /* the clone has one default argument less, the orignal has all default arguments removed */
326 ArgList* magicClone() {
327 ArgList* l = new ArgList;
328 bool firstDefault = FALSE;
329 for ( first(); current(); next() ) {
330 bool isDefault = current()->isDefault;
331 if ( !firstDefault && isDefault ) {
332 isDefault = FALSE;
333 firstDefault = TRUE;
334 }
335 l->append( new Argument( current()->leftType, current()->rightType, current()->name, isDefault ) );
336 }
337 for ( first(); current(); ) {
338 if ( current()->isDefault )
339 remove();
340 else
341 next();
342 }
343 return l;
344 }
345
346 bool hasDefaultArguments() {
347 for ( Argument* a = first(); a; a = next() ) {
348 if ( a->isDefault )
349 return TRUE;
350 }
351 return FALSE;
352 }
353
354};
355
356
357struct Function /* member function meta data*/
358{
359 Access access;
360 QCString qualifier; /* const or volatile*/
361 QCString name;
362 QCString type;
363 QCString signature;
364 int lineNo;
365 ArgList *args;
366 Function() { args=0;}
367 ~Function() { delete args; }
368 const char* accessAsString() {
369 switch ( access ) {
370 case Private: return "Private";
371 case Protected: return "Protected";
372 default: return "Public";
373 }
374 }
375};
376
377class FuncList : public QPtrList<Function> { /* list of member functions*/
378public:
379 FuncList( bool autoDelete = FALSE ) { setAutoDelete( autoDelete ); }
380
381 FuncList find( const char* name )
382 {
383 FuncList result;
384 for ( QPtrListIterator<Function> it(*this); it.current(); ++it ) {
385 if ( it.current()->name == name )
386 result.append( it.current() );
387 }
388 return result;
389 }
390};
391
392class Enum : public QStrList
393{
394public:
395 QCString name;
396 bool set;
397};
398
399class EnumList : public QPtrList<Enum> { /* list of property enums*/
400public:
401 EnumList() { setAutoDelete(TRUE); }
402};
403
404
405struct Property
406{
407 Property( int l, const char* t, const char* n, const char* s, const char* g, const char* r,
408 const QCString& st, const QCString& d, const QCString& sc, bool ov )
409 : lineNo(l), type(t), name(n), set(s), get(g), reset(r), setfunc(0), getfunc(0),
410 sspec(Unspecified), gspec(Unspecified), stored( st ),
411 designable( d ), scriptable( sc ), override( ov ), oredEnum( -1 )
412 {
413 /*
414 The Q_PROPERTY construct cannot contain any commas, since
415 commas separate macro arguments. We therefore expect users
416 to type "QMap" instead of "QMap<QString, QVariant>". For
417 coherence, we also expect the same for
418 QValueList<QVariant>, the other template class supported by
419 QVariant.
420 */
421 if ( type == "QMap" ) {
422 type = "QMap<QString,QVariant>";
423 } else if ( type == "QValueList" ) {
424 type = "QValueList<QVariant>";
425 } else if ( type == "LongLong" ) {
426 type = "Q_LLONG";
427 } else if ( type == "ULongLong" ) {
428 type = "Q_ULLONG";
429 }
430 }
431
432 int lineNo;
433 QCString type;
434 QCString name;
435 QCString set;
436 QCString get;
437 QCString reset;
438 QCString stored;
439 QCString designable;
440 QCString scriptable;
441 bool override;
442
443 Function* setfunc;
444 Function* getfunc;
445
446 int oredEnum; /* If the enums item may be ored. That means the data type is int.*/
447 /* Allowed values are 1 (True), 0 (False), and -1 (Unset)*/
448 QCString enumsettype; /* contains the set function type in case of oredEnum*/
449 QCString enumgettype; /* contains the get function type in case of oredEnum*/
450
451 enum Specification { Unspecified, Class, Reference, Pointer, ConstCharStar };
452 Specification sspec;
453 Specification gspec;
454
455 bool stdSet() {
456 QCString s = "set";
457 s += toupper( name[0] );
458 s += name.mid( 1 );
459 return s == set;
460 }
461
462 static const char* specToString( Specification s )
463 {
464 switch ( s ) {
465 case Class:
466 return "Class";
467 case Reference:
468 return "Reference";
469 case Pointer:
470 return "Pointer";
471 case ConstCharStar:
472 return "ConstCharStar";
473 default:
474 return "Unspecified";
475 }
476 }
477};
478
479class PropList : public QPtrList<Property> { /* list of properties*/
480public:
481 PropList() { setAutoDelete( TRUE ); }
482};
483
484
485struct ClassInfo
486{
487 ClassInfo( const char* n, const char* v )
488 : name(n), value(v)
489 {}
490 QCString name;
491 QCString value;
492};
493
494class ClassInfoList : public QPtrList<ClassInfo> { /* list of class infos*/
495public:
496 ClassInfoList() { setAutoDelete( TRUE ); }
497};
498
499class parser_reg {
500 public:
501 parser_reg();
502 ~parser_reg();
503
504 /* some temporary values*/
505 QCString tmpExpression; /* Used to store the characters the lexer*/
506 /* is currently skipping (see addExpressionChar and friends)*/
507 QCString fileName; /* file name*/
508 QCString outputFile; /* output file name*/
509 QCString pchFile; /* name of PCH file (used on Windows)*/
510 QStrList includeFiles; /* name of #include files*/
511 QCString includePath; /* #include file path*/
512 QCString qtPath; /* #include qt file path*/
513 int gen_count; /*number of classes generated*/
514 bool noInclude; /* no #include <filename>*/
515 bool generatedCode; /* no code generated*/
516 bool mocError; /* moc parsing error occurred*/
517 bool hasVariantIncluded; /*whether or not qvariant.h was included yet*/
518 QCString className; /* name of parsed class*/
519 QCString superClassName; /* name of first super class*/
520 QStrList multipleSuperClasses; /* other superclasses*/
521 FuncList signals; /* signal interface*/
522 FuncList slots; /* slots interface*/
523 FuncList propfuncs; /* all possible property access functions*/
524 FuncList funcs; /* all parsed functions, including signals*/
525 EnumList enums; /* enums used in properties*/
526 PropList props; /* list of all properties*/
527 ClassInfoList infos; /* list of all class infos*/
528
529/* Used to store the values in the Q_PROPERTY macro*/
530 QCString propWrite; /* set function*/
531 QCString propRead; /* get function*/
532 QCString propReset; /* reset function*/
533 QCString propStored; /**/
534 QCString propDesignable; /* "true", "false" or function or empty if not specified*/
535 QCString propScriptable; /* "true", "false" or function or empty if not specified*/
536 bool propOverride; /* Wether OVERRIDE was detected*/
537
538 QStrList qtEnums; /* Used to store the contents of Q_ENUMS*/
539 QStrList qtSets; /* Used to store the contents of Q_SETS*/
540
541};
542
543static parser_reg *g = 0;
544
545ArgList *addArg( Argument * ); /* add arg to tmpArgList*/
546
547enum Member { SignalMember,
548 SlotMember,
549 PropertyCandidateMember
550 };
551
552void addMember( Member ); /* add tmpFunc to current class*/
553void addEnum(); /* add tmpEnum to current class*/
554
555char *stradd( const char *, const char * ); /* add two strings*/
556char *stradd( const char *, const char *, /* add three strings*/
557 const char * );
558char *stradd( const char *, const char *, /* adds 4 strings*/
559 const char *, const char * );
560
561char *straddSpc( const char *, const char * );
562char *straddSpc( const char *, const char *,
563 const char * );
564char *straddSpc( const char *, const char *,
565 const char *, const char * );
566
567extern int yydebug;
568bool lexDebug = FALSE;
569int lineNo; /* current line number*/
570bool errorControl = FALSE; /* controled errors*/
571bool displayWarnings = TRUE;
572bool skipClass; /* don't generate for class*/
573bool skipFunc; /* don't generate for func*/
574bool templateClass; /* class is a template*/
575bool templateClassOld; /* previous class is a template*/
576
577ArgList *tmpArgList; /* current argument list*/
578Function *tmpFunc; /* current member function*/
579Enum *tmpEnum; /* current enum*/
580Access tmpAccess; /* current access permission*/
581Access subClassPerm; /* current access permission*/
582
583bool Q_OBJECTdetected; /* TRUE if current class*/
584 /* contains the Q_OBJECT macro*/
585bool Q_PROPERTYdetected; /* TRUE if current class*/
586 /* contains at least one Q_PROPERTY,*/
587 /* Q_OVERRIDE, Q_SETS or Q_ENUMS macro*/
588bool tmpPropOverride; /* current property override setting*/
589
590int tmpYYStart; /* Used to store the lexers current mode*/
591int tmpYYStart2; /* Used to store the lexers current mode*/
592 /* (if tmpYYStart is already used)*/
593
594/* if the format revision changes, you MUST change it in qmetaobject.h too*/
595const int formatRevision = 26; /* moc output format revision*/
596
597/* if the flags change, you HAVE to change it in qmetaobject.h too*/
598enum Flags {
599 Invalid = 0x00000000,
600 Readable = 0x00000001,
601 Writable = 0x00000002,
602 EnumOrSet = 0x00000004,
603 UnresolvedEnum = 0x00000008,
604 StdSet = 0x00000100,
605 Override = 0x00000200,
606 NotDesignable = 0x00001000,
607 DesignableOverride = 0x00002000,
608 NotScriptable = 0x00004000,
609 ScriptableOverride = 0x00008000,
610 NotStored = 0x00010000,
611 StoredOverride = 0x00020000
612};
613
614#line 662 "moc.y"
615typedef union {
616 char char_val;
617 int int_val;
618 double double_val;
619 char *string;
620 Access access;
621 Function *function;
622 ArgList *arg_list;
623 Argument *arg;
624} YYSTYPE;
625#line 626 "y.tab.c"
626#define CHAR_VAL 257
627#define INT_VAL 258
628#define DOUBLE_VAL 259
629#define STRING 260
630#define IDENTIFIER 261
631#define FRIEND 262
632#define TYPEDEF 263
633#define AUTO 264
634#define REGISTER 265
635#define STATIC 266
636#define EXTERN 267
637#define INLINE 268
638#define VIRTUAL 269
639#define CONST 270
640#define VOLATILE 271
641#define CHAR 272
642#define SHORT 273
643#define INT 274
644#define LONG 275
645#define SIGNED 276
646#define UNSIGNED 277
647#define FLOAT 278
648#define DOUBLE 279
649#define VOID 280
650#define ENUM 281
651#define CLASS 282
652#define STRUCT 283
653#define UNION 284
654#define ASM 285
655#define PRIVATE 286
656#define PROTECTED 287
657#define PUBLIC 288
658#define OPERATOR 289
659#define DBL_COLON 290
660#define TRIPLE_DOT 291
661#define TEMPLATE 292
662#define NAMESPACE 293
663#define USING 294
664#define MUTABLE 295
665#define THROW 296
666#define SIGNALS 297
667#define SLOTS 298
668#define Q_OBJECT 299
669#define Q_PROPERTY 300
670#define Q_OVERRIDE 301
671#define Q_CLASSINFO 302
672#define Q_ENUMS 303
673#define Q_SETS 304
674#define READ 305
675#define WRITE 306
676#define STORED 307
677#define DESIGNABLE 308
678#define SCRIPTABLE 309
679#define RESET 310
680#define YYERRCODE 256
681short yylhs[] = { -1,
682 0, 0, 40, 40, 40, 40, 40, 42, 42, 48,
683 50, 46, 51, 52, 47, 49, 43, 45, 44, 44,
684 54, 41, 1, 1, 2, 55, 56, 57, 58, 30,
685 30, 30, 30, 30, 29, 31, 31, 32, 32, 59,
686 59, 59, 59, 34, 34, 33, 33, 11, 11, 11,
687 12, 12, 13, 13, 13, 13, 13, 13, 13, 13,
688 13, 3, 60, 60, 14, 14, 15, 15, 16, 16,
689 17, 17, 17, 19, 19, 21, 21, 25, 25, 61,
690 61, 20, 20, 24, 62, 24, 24, 63, 24, 22,
691 22, 23, 64, 23, 65, 23, 23, 23, 35, 35,
692 66, 35, 35, 39, 67, 10, 10, 73, 10, 74,
693 10, 75, 72, 76, 72, 38, 38, 37, 37, 36,
694 36, 26, 26, 27, 27, 28, 28, 71, 71, 71,
695 78, 77, 81, 53, 53, 53, 53, 53, 53, 18,
696 18, 18, 18, 18, 82, 82, 79, 83, 69, 69,
697 84, 68, 68, 85, 86, 86, 88, 87, 4, 4,
698 80, 80, 89, 89, 91, 91, 93, 90, 94, 90,
699 90, 96, 99, 90, 100, 101, 90, 102, 103, 90,
700 104, 106, 90, 107, 109, 90, 92, 92, 111, 92,
701 92, 98, 98, 112, 112, 113, 95, 95, 115, 115,
702 116, 110, 110, 117, 117, 118, 119, 119, 5, 6,
703 6, 7, 7, 8, 8, 8, 8, 8, 8, 8,
704 8, 8, 8, 9, 9, 9, 120, 120, 120, 120,
705 120, 120, 120, 120, 120, 120, 120, 120, 120, 120,
706 120, 120, 120, 120, 120, 120, 120, 120, 120, 120,
707 120, 120, 120, 120, 120, 120, 120, 120, 120, 120,
708 120, 120, 120, 120, 120, 120, 120, 121, 121, 122,
709 122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
710 122, 114, 114, 114, 114, 114, 114, 114, 114, 126,
711 127, 114, 124, 124, 128, 129, 128, 130, 128, 123,
712 131, 123, 125, 133, 133, 132, 132, 70, 70, 134,
713 134, 134, 135, 136, 135, 138, 97, 137, 137, 137,
714 137, 137, 137, 137, 105, 105, 108, 108,
715};
716short yylen[] = { 2,
717 0, 2, 1, 1, 1, 1, 1, 1, 1, 0,
718 0, 7, 0, 0, 6, 1, 5, 2, 2, 2,
719 0, 3, 1, 1, 4, 0, 0, 0, 0, 1,
720 1, 1, 1, 1, 3, 0, 1, 1, 2, 1,
721 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
722 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
723 1, 4, 0, 1, 2, 2, 1, 2, 3, 1,
724 2, 2, 2, 2, 3, 0, 1, 0, 1, 0,
725 1, 3, 1, 2, 0, 5, 4, 0, 7, 0,
726 1, 2, 0, 4, 0, 5, 1, 3, 1, 2,
727 0, 5, 3, 1, 8, 1, 2, 0, 4, 0,
728 5, 0, 4, 0, 5, 0, 1, 1, 2, 2,
729 2, 0, 1, 1, 2, 1, 1, 1, 1, 3,
730 0, 3, 0, 5, 1, 3, 3, 4, 2, 1,
731 1, 1, 1, 1, 2, 3, 2, 3, 0, 1,
732 4, 0, 1, 2, 1, 3, 0, 5, 0, 1,
733 0, 1, 2, 1, 1, 1, 0, 3, 0, 4,
734 1, 0, 0, 7, 0, 0, 7, 0, 0, 9,
735 0, 0, 7, 0, 0, 7, 2, 3, 0, 3,
736 1, 0, 1, 2, 1, 1, 0, 1, 2, 1,
737 1, 0, 1, 2, 1, 1, 0, 2, 2, 3,
738 1, 4, 4, 1, 3, 2, 3, 2, 1, 3,
739 2, 3, 2, 1, 1, 1, 3, 3, 1, 1,
740 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
741 1, 2, 2, 2, 2, 2, 2, 2, 2, 2,
742 2, 2, 2, 2, 2, 2, 3, 3, 2, 2,
743 2, 2, 1, 3, 2, 2, 2, 0, 1, 2,
744 1, 3, 5, 2, 3, 4, 3, 2, 6, 4,
745 5, 3, 4, 6, 4, 4, 5, 3, 3, 0,
746 0, 7, 1, 3, 1, 0, 4, 0, 3, 0,
747 0, 3, 2, 0, 1, 5, 4, 0, 1, 0,
748 1, 3, 1, 0, 4, 0, 4, 0, 3, 3,
749 3, 3, 3, 3, 0, 2, 0, 2,
750};
751short yydefred[] = { 1,
752 0, 0, 0, 2, 3, 4, 5, 6, 7, 8,
753 9, 0, 0, 0, 19, 20, 18, 0, 0, 0,
754 0, 0, 0, 0, 0, 0, 14, 26, 140, 40,
755 41, 42, 43, 44, 45, 46, 47, 53, 54, 55,
756 56, 57, 58, 59, 60, 61, 141, 139, 142, 144,
757 143, 0, 70, 24, 0, 22, 65, 66, 133, 0,
758 0, 0, 0, 147, 160, 0, 0, 0, 0, 11,
759 1, 0, 26, 146, 0, 0, 0, 136, 137, 0,
760 0, 224, 225, 226, 0, 219, 211, 0, 214, 0,
761 17, 1, 0, 0, 62, 0, 69, 169, 166, 171,
762 172, 175, 178, 181, 184, 165, 0, 0, 164, 167,
763 138, 0, 221, 0, 216, 0, 0, 223, 218, 0,
764 15, 25, 0, 0, 0, 0, 0, 0, 134, 163,
765 0, 0, 0, 220, 215, 210, 222, 217, 12, 0,
766 0, 0, 0, 0, 0, 191, 0, 0, 189, 168,
767 212, 213, 0, 33, 34, 0, 0, 0, 0, 0,
768 0, 64, 271, 0, 0, 52, 0, 49, 48, 38,
769 0, 31, 32, 30, 0, 170, 201, 0, 200, 0,
770 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
771 187, 0, 0, 108, 112, 0, 0, 0, 303, 73,
772 0, 0, 0, 263, 0, 0, 0, 0, 0, 0,
773 0, 0, 0, 0, 0, 0, 0, 0, 278, 0,
774 0, 0, 0, 0, 0, 0, 270, 0, 118, 0,
775 51, 0, 0, 0, 0, 0, 39, 290, 207, 199,
776 0, 0, 301, 207, 0, 309, 0, 316, 173, 176,
777 0, 326, 182, 328, 185, 188, 206, 0, 205, 190,
778 0, 195, 196, 27, 27, 110, 114, 0, 0, 0,
779 311, 252, 253, 0, 254, 0, 267, 266, 244, 248,
780 259, 242, 261, 243, 0, 262, 245, 246, 247, 249,
781 260, 250, 251, 0, 0, 288, 0, 207, 277, 126,
782 127, 120, 0, 124, 121, 0, 0, 0, 275, 119,
783 148, 72, 0, 71, 0, 0, 272, 0, 0, 0,
784 83, 0, 0, 27, 0, 207, 0, 207, 0, 0,
785 0, 0, 0, 0, 204, 194, 109, 0, 27, 27,
786 0, 314, 0, 0, 257, 258, 264, 227, 228, 207,
787 0, 125, 0, 276, 280, 0, 291, 208, 0, 0,
788 81, 74, 93, 0, 0, 0, 97, 0, 302, 0,
789 0, 0, 298, 0, 99, 0, 293, 0, 0, 0,
790 0, 0, 0, 0, 317, 174, 177, 179, 183, 186,
791 113, 111, 0, 0, 29, 312, 307, 0, 281, 0,
792 273, 0, 0, 75, 82, 27, 0, 104, 85, 0,
793 95, 92, 35, 296, 0, 27, 101, 100, 207, 0,
794 0, 0, 0, 0, 0, 0, 0, 115, 306, 315,
795 279, 207, 0, 0, 153, 0, 98, 28, 0, 27,
796 27, 103, 299, 27, 0, 294, 319, 320, 322, 323,
797 324, 321, 180, 0, 0, 154, 0, 0, 0, 150,
798 94, 86, 88, 0, 297, 0, 157, 0, 0, 0,
799 28, 96, 102, 27, 156, 79, 0, 131, 0, 128,
800 105, 129, 89, 0, 151, 0, 0, 158, 132, 130,
801};
802short yydgoto[] = { 93,
803 53, 54, 162, 64, 65, 85, 86, 87, 88, 163,
804 164, 165, 166, 167, 168, 69, 169, 48, 318, 319,
805 320, 365, 366, 321, 477, 302, 303, 304, 322, 170,
806 217, 171, 172, 173, 374, 229, 306, 307, 375, 4,
807 5, 6, 7, 8, 9, 10, 11, 26, 94, 92,
808 14, 71, 21, 12, 72, 337, 462, 430, 174, 22,
809 362, 438, 471, 406, 440, 444, 244, 434, 459, 247,
810 481, 196, 264, 339, 265, 340, 482, 486, 23, 107,
811 76, 24, 175, 460, 435, 456, 457, 474, 108, 109,
812 110, 150, 131, 123, 176, 124, 184, 260, 330, 125,
813 331, 126, 427, 127, 188, 333, 128, 190, 334, 256,
814 193, 261, 262, 263, 178, 179, 258, 259, 316, 219,
815 180, 181, 245, 376, 182, 315, 402, 377, 441, 416,
816 324, 199, 344, 270, 271, 395, 385, 329,
817};
818short yysindex[] = { 0,
819 70, -206, -111, 0, 0, 0, 0, 0, 0, 0,
820 0, -220, 41, 10, 0, 0, 0, 67, 912, -96,
821 152, 124, 91, 559, -81, 98, 0, 0, 0, 0,
822 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
823 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
824 0, 11, 0, 0, -54, 0, 0, 0, 0, -14,
825 -3, 59, 354, 0, 0, 201, 61, 233, -54, 0,
826 0, 266, 0, 0, 61, 1186, 329, 0, 0, 206,
827 245, 0, 0, 0, 328, 0, 0, -83, 0, -54,
828 0, 0, 70, 287, 0, 348, 0, 0, 0, 0,
829 0, 0, 0, 0, 0, 0, 295, 1186, 0, 0,
830 0, 438, 0, -66, 0, 354, -66, 0, 0, 303,
831 0, 0, 384, 406, 411, 457, 468, 480, 0, 0,
832 -42, 434, 481, 0, 0, 0, 0, 0, 0, 1064,
833 265, 265, 291, 292, 306, 0, 506, 515, 0, 0,
834 0, 0, 353, 0, 0, 0, -71, 315, 467, 337,
835 -48, 0, 0, 276, 1230, 0, 374, 0, 0, 0,
836 1098, 0, 0, 0, -26, 0, 0, 1064, 0, 436,
837 119, 375, 377, 568, 575, 545, 292, 604, 306, 607,
838 0, 1064, 1064, 0, 0, -30, 520, 389, 0, 0,
839 596, 393, 394, 0, 570, 624, 600, 177, 355, 379,
840 605, 606, 609, 22, 612, 613, 986, 1229, 0, 572,
841 -81, 635, 13, 467, 349, 349, 0, 363, 0, -36,
842 0, 201, -53, 440, 1229, 441, 0, 0, 0, 0,
843 443, 1229, 0, 0, 204, 0, 649, 0, 0, 0,
844 463, 0, 0, 0, 0, 0, 0, 1064, 0, 0,
845 1064, 0, 0, 0, 0, 0, 0, 389, 664, 665,
846 0, 0, 0, 702, 0, 708, 0, 0, 0, 0,
847 0, 0, 0, 0, 626, 0, 0, 0, 0, 0,
848 0, 0, 0, 285, 285, 0, 667, 0, 0, 0,
849 0, 0, 349, 0, 0, 285, -201, 467, 0, 0,
850 0, 0, 285, 0, 599, 724, 0, 743, 742, 494,
851 0, 277, 1119, 0, 724, 0, -21, 0, 764, 1064,
852 1064, 746, 1064, 1064, 0, 0, 0, 719, 0, 0,
853 665, 0, 389, 693, 0, 0, 0, 0, 0, 0,
854 724, 0, 467, 0, 0, -38, 0, 0, 349, 784,
855 0, 0, 0, 277, -22, 178, 0, 1229, 0, 724,
856 798, 29, 0, 407, 0, 458, 0, 724, 601, 617,
857 622, 625, 646, 647, 0, 0, 0, 0, 0, 0,
858 0, 0, 786, 762, 0, 0, 0, 724, 0, 467,
859 0, 874, 881, 0, 0, 0, 65, 0, 0, 277,
860 0, 0, 0, 0, 385, 0, 0, 0, 0, -21,
861 764, 764, 764, 764, 764, 764, 1064, 0, 0, 0,
862 0, 0, -81, 657, 0, 861, 0, 0, 894, 0,
863 0, 0, 0, 0, 724, 0, 0, 0, 0, 0,
864 0, 0, 0, 724, 916, 0, 913, 948, 375, 0,
865 0, 0, 0, 889, 0, 933, 0, -81, 1229, 26,
866 0, 0, 0, 0, 0, 0, 991, 0, 799, 0,
867 0, 0, 0, 1015, 0, 936, 1004, 0, 0, 0,
868};
869short yyrindex[] = { 0,
870 330, 941, 0, 0, 0, 0, 0, 0, 0, 0,
871 0, 199, 943, 0, 0, 0, 0, 0, 373, 0,
872 0, 0, 0, 5, 0, 0, 0, 0, 0, 0,
873 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
874 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
875 0, 76, 0, 0, 327, 0, 0, 0, 0, 0,
876 0, 0, 0, 0, 0, 40, 0, 0, 71, 0,
877 0, 0, 0, 0, 0, 940, 0, 0, 0, 31,
878 0, 0, 0, 0, 78, 0, 0, 0, 0, 82,
879 0, 0, -90, 0, 0, 0, 0, 0, 0, 0,
880 0, 0, 0, 0, 0, 0, 0, 953, 0, 0,
881 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
882 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
883 0, 0, 0, 0, 0, 0, 0, 0, 0, 594,
884 0, 0, 0, 1062, 1068, 0, 0, 0, 0, 0,
885 0, 0, 113, 0, 0, 1032, 0, 0, 1140, 0,
886 0, 0, 0, 0, 126, 0, 0, 0, 0, 0,
887 199, 0, 0, 0, 0, 0, 0, 602, 0, 0,
888 504, 1065, 0, 0, 0, 0, 1062, 0, 1068, 0,
889 0, 911, 934, 0, 0, 516, 316, 33, 0, 0,
890 548, 618, 620, 0, 0, 0, 663, 1018, 1160, 1209,
891 1364, 1366, 1386, 1388, 1391, 1393, 0, 4, 0, 0,
892 0, 0, 1396, 1140, -18, -18, 0, 37, 0, 0,
893 0, 168, 80, 0, 191, 0, 0, 0, 0, 0,
894 0, 187, 0, 0, 0, 0, 0, 0, 0, 0,
895 0, 0, 0, 0, 0, 0, 0, 942, 0, 0,
896 988, 0, 0, 0, 0, 0, 0, 33, 49, 998,
897 0, 0, 0, 1398, 0, 1418, 0, 0, 0, 0,
898 0, 0, 0, 0, 1420, 0, 0, 0, 0, 0,
899 0, 0, 0, 1423, 1423, 0, 0, 0, 0, 0,
900 0, 0, -29, 0, 0, 360, 0, 1140, 0, 0,
901 0, 0, 37, 0, 0, 478, 0, 0, -37, 1084,
902 0, -27, 199, 0, 527, 0, 0, 0, 1085, 934,
903 934, 0, 934, 934, 0, 0, 0, 0, 0, 0,
904 998, 0, 1002, 0, 0, 0, 0, 0, 0, 0,
905 571, 0, 1140, 0, 0, 0, 0, 0, 298, 408,
906 0, 0, 0, 0, -23, 64, 0, 9, 0, 648,
907 477, 0, 0, 510, 0, 0, 0, 697, 0, 0,
908 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
909 0, 0, 0, 0, 0, 0, 0, 741, 0, 1140,
910 0, 0, 238, 0, 0, 0, 0, 0, 0, -34,
911 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
912 1085, 1085, 1085, 1085, 1085, 1085, 934, 0, 0, 0,
913 0, 0, 0, -2, 0, 0, 0, 0, -16, 0,
914 0, 0, 0, 0, 818, 0, 0, 0, 0, 0,
915 0, 0, 0, 867, 0, 0, 350, 0, 58, 0,
916 0, 0, 0, 0, 0, 0, 0, 0, 211, 0,
917 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
918 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
919};
920short yygindex[] = { 1152,
921 347, 0, 1150, 930, 0, 0, 435, 1056, 449, 283,
922 -135, 0, 57, -11, -25, 122, 0, 0, 0, 0,
923 0, 765, 810, -294, 0, -159, 0, 892, 0, -10,
924 -44, -156, 1177, 1182, 830, 244, 1039, 301, 840, 0,
925 0, 0, 0, 0, 0, 0, 0, 0, 1114, 0,
926 0, 0, 0, 0, 1134, 231, 752, 0, 1207, 0,
927 0, 0, 0, 0, 0, 0, 0, 0, 0, 768,
928 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
929 0, 0, 0, 0, 0, 780, 0, 0, 0, 1142,
930 0, 0, 0, 0, 0, 0, 1109, -186, 0, 0,
931 0, 0, 0, 0, 1067, 0, 0, 1063, 0, 0,
932 0, 0, 994, -82, 0, 1078, 0, 999, 274, -170,
933 0, 0, 0, 0, 0, 0, 0, 849, 0, 0,
934 0, 0, 931, 1005, 974, 0, 856, 0,
935};
936#define YYTABLESIZE 1510
937short yytable[] = { 68,
938 20, 226, 218, 77, 63, 225, 90, 228, 123, 90,
939 123, 123, 123, 90, 123, 149, 90, 84, 372, 122,
940 84, 122, 122, 122, 87, 122, 90, 87, 123, 123,
941 266, 123, 239, 90, 16, 235, 373, 89, 409, 122,
942 122, 37, 122, 37, 37, 37, 36, 37, 36, 36,
943 36, 198, 36, 299, 13, 115, 149, 177, 149, 223,
944 267, 123, 119, 135, 37, 405, 305, 218, 372, 36,
945 73, 18, 122, 194, 23, 47, 310, 23, 218, 23,
946 23, 23, 290, 23, 480, 218, 479, 353, 135, 23,
947 89, 138, 313, 123, 37, 177, 238, 23, 23, 36,
948 23, 25, 226, 195, 91, 437, 225, 91, 67, 257,
949 67, 67, 67, 23, 67, 23, 308, 23, 308, 68,
950 149, 68, 68, 68, 91, 68, 28, 159, 67, 67,
951 23, 67, 27, 23, 23, 222, 209, 355, 159, 68,
952 68, 55, 68, 386, 387, 291, 389, 390, 478, 15,
953 23, 218, 106, 23, 23, 411, 106, 310, 242, 236,
954 237, 67, 23, 50, 52, 50, 50, 50, 133, 50,
955 106, 106, 68, 313, 476, 257, 243, 80, 16, 66,
956 308, 17, 399, 50, 50, 117, 50, 368, 90, 197,
957 313, 21, 21, 67, 80, 297, 218, 323, 23, 403,
958 209, 21, 159, 218, 68, 71, 67, 237, 67, 71,
959 56, 218, 66, 59, 281, 226, 50, 237, 146, 225,
960 70, 231, 223, 67, 223, 23, 23, 76, 36, 431,
961 274, 123, 36, 90, 274, 75, 75, 280, 408, 371,
962 453, 67, 122, 218, 221, 112, 77, 327, 274, 274,
963 400, 78, 308, 77, 147, 148, 90, 78, 149, 123,
964 73, 123, 326, 90, 37, 73, 123, 84, 411, 36,
965 122, 66, 122, 295, 87, 37, 37, 37, 37, 37,
966 37, 37, 37, 37, 37, 37, 37, 37, 233, 408,
967 23, 91, 37, 37, 37, 37, 152, 116, 152, 36,
968 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
969 23, 236, 218, 226, 226, 323, 364, 225, 225, 79,
970 23, 66, 226, 413, 91, 116, 225, 95, 23, 23,
971 23, 67, 67, 67, 67, 67, 67, 67, 67, 67,
972 67, 67, 68, 68, 68, 68, 68, 68, 68, 68,
973 68, 68, 68, 72, 91, 122, 122, 72, 122, 67,
974 152, 67, 2, 3, 145, 23, 145, 363, 145, 111,
975 68, 116, 68, 23, 23, 23, 23, 23, 23, 23,
976 23, 23, 23, 23, 145, 145, 50, 50, 50, 50,
977 50, 50, 50, 50, 50, 50, 50, 283, 74, 117,
978 226, 23, 23, 117, 225, 57, 58, 455, 155, 122,
979 155, 121, 73, 194, 50, 282, 50, 117, 117, 129,
980 122, 97, 226, 286, 323, 442, 225, 139, 71, 71,
981 71, 71, 71, 71, 71, 71, 71, 71, 71, 284,
982 285, 140, 455, 195, 226, 141, 227, 36, 225, 145,
983 142, 36, 274, 273, 275, 276, 71, 23, 36, 36,
984 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
985 36, 36, 155, 310, 151, 417, 36, 76, 36, 36,
986 63, 63, 36, 36, 36, 36, 36, 36, 36, 36,
987 36, 36, 36, 36, 36, 338, 143, 417, 152, 216,
988 36, 420, 36, 212, 208, 80, 206, 144, 207, 209,
989 204, 210, 309, 211, 104, 113, 419, 325, 104, 145,
990 104, 152, 118, 317, 106, 183, 202, 201, 203, 114,
991 82, 83, 84, 152, 67, 104, 223, 154, 155, 30,
992 31, 32, 33, 34, 35, 36, 37, 300, 134, 310,
993 186, 137, 187, 295, 369, 107, 106, 205, 122, 107,
994 213, 241, 300, 191, 224, 367, 189, 104, 295, 392,
995 393, 351, 192, 107, 107, 200, 72, 72, 72, 72,
996 72, 72, 72, 72, 72, 72, 72, 239, 251, 354,
997 214, 239, 215, 122, 348, 349, 62, 220, 60, 370,
998 61, 378, 289, 289, 72, 239, 239, 367, 249, 412,
999 155, 21, 21, 356, 80, 250, 63, 418, 300, 301,
1000 117, 21, 81, 398, 154, 155, 30, 31, 32, 33,
1001 34, 35, 36, 37, 232, 246, 436, 248, 401, 82,
1002 83, 84, 268, 67, 253, 155, 443, 255, 117, 269,
1003 412, 282, 282, 367, 64, 64, 272, 240, 418, 241,
1004 279, 240, 277, 241, 278, 287, 288, 347, 36, 289,
1005 464, 465, 292, 293, 466, 240, 240, 241, 241, 36,
1006 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
1007 36, 36, 445, 298, 296, 286, 286, 36, 132, 36,
1008 312, 314, 231, 223, 484, 454, 231, 328, 343, 38,
1009 39, 40, 41, 42, 43, 44, 45, 46, 197, 268,
1010 231, 231, 332, 357, 342, 350, 198, 268, 154, 155,
1011 30, 31, 32, 33, 34, 35, 36, 37, 289, 289,
1012 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
1013 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
1014 289, 289, 345, 289, 289, 289, 289, 289, 346, 289,
1015 289, 289, 283, 283, 289, 289, 289, 289, 289, 289,
1016 289, 289, 358, 359, 361, 360, 388, 282, 282, 282,
1017 282, 282, 282, 282, 282, 282, 282, 282, 282, 282,
1018 282, 282, 282, 282, 282, 282, 282, 282, 282, 282,
1019 282, 391, 282, 282, 282, 282, 282, 397, 282, 282,
1020 282, 285, 285, 282, 282, 282, 282, 282, 282, 282,
1021 282, 286, 286, 286, 286, 286, 286, 286, 286, 286,
1022 286, 286, 286, 286, 286, 286, 286, 286, 286, 286,
1023 286, 286, 286, 286, 286, 414, 286, 286, 286, 286,
1024 286, 421, 286, 286, 286, 287, 287, 286, 286, 286,
1025 286, 286, 286, 286, 286, 63, 63, 422, 428, 197,
1026 197, 197, 423, 63, 63, 424, 429, 198, 198, 198,
1027 197, 197, 197, 197, 197, 197, 197, 197, 198, 198,
1028 198, 198, 198, 198, 198, 198, 425, 426, 283, 283,
1029 283, 283, 283, 283, 283, 283, 283, 283, 283, 283,
1030 283, 283, 283, 283, 283, 283, 283, 283, 283, 283,
1031 283, 283, 432, 283, 283, 283, 283, 283, 433, 283,
1032 283, 283, 284, 284, 283, 283, 283, 283, 283, 283,
1033 283, 283, 458, 461, 463, 467, 468, 285, 285, 285,
1034 285, 285, 285, 285, 285, 285, 285, 285, 285, 285,
1035 285, 285, 285, 285, 285, 285, 285, 285, 285, 285,
1036 285, 472, 285, 285, 285, 285, 285, 469, 285, 285,
1037 285, 292, 292, 285, 285, 285, 285, 285, 285, 285,
1038 285, 287, 287, 287, 287, 287, 287, 287, 287, 287,
1039 287, 287, 287, 287, 287, 287, 287, 287, 287, 287,
1040 287, 287, 287, 287, 287, 473, 287, 287, 287, 287,
1041 287, 485, 287, 287, 287, 202, 268, 287, 287, 287,
1042 287, 287, 287, 287, 287, 154, 155, 30, 31, 32,
1043 33, 34, 35, 36, 37, 488, 487, 235, 192, 268,
1044 489, 235, 490, 13, 161, 10, 203, 268, 379, 380,
1045 381, 382, 383, 384, 404, 235, 235, 162, 284, 284,
1046 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
1047 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
1048 284, 284, 325, 284, 284, 284, 284, 284, 327, 284,
1049 284, 284, 193, 268, 284, 284, 284, 284, 284, 284,
1050 284, 284, 304, 308, 80, 318, 305, 292, 292, 292,
1051 292, 292, 292, 292, 292, 292, 292, 292, 292, 292,
1052 292, 292, 292, 292, 292, 292, 292, 292, 292, 292,
1053 292, 1, 292, 292, 292, 292, 292, 269, 292, 292,
1054 292, 19, 311, 292, 292, 292, 292, 292, 292, 292,
1055 292, 136, 29, 407, 439, 30, 31, 32, 33, 34,
1056 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1057 45, 46, 63, 63, 352, 49, 202, 202, 202, 229,
1058 50, 415, 230, 229, 410, 120, 96, 202, 202, 202,
1059 202, 202, 202, 202, 202, 63, 63, 229, 229, 192,
1060 192, 192, 483, 63, 63, 51, 470, 203, 203, 203,
1061 192, 192, 192, 192, 192, 192, 192, 192, 203, 203,
1062 203, 203, 203, 203, 203, 203, 294, 475, 230, 130,
1063 185, 254, 230, 252, 336, 240, 335, 38, 39, 40,
1064 41, 42, 43, 44, 45, 46, 230, 230, 446, 63,
1065 63, 394, 341, 193, 193, 193, 447, 448, 449, 450,
1066 451, 452, 0, 0, 193, 193, 193, 193, 193, 193,
1067 193, 193, 45, 45, 45, 45, 45, 45, 45, 45,
1068 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
1069 45, 45, 45, 45, 45, 45, 396, 0, 0, 0,
1070 0, 45, 0, 45, 153, 154, 155, 30, 31, 32,
1071 33, 34, 156, 36, 37, 38, 39, 40, 41, 42,
1072 43, 44, 45, 46, 157, 0, 0, 158, 0, 0,
1073 0, 0, 159, 67, 0, 18, 160, 161, 66, 154,
1074 155, 30, 31, 32, 33, 34, 35, 36, 37, 38,
1075 39, 40, 41, 42, 43, 44, 45, 46, 234, 66,
1076 0, 158, 0, 0, 0, 0, 0, 67, 0, 18,
1077 38, 39, 40, 41, 42, 43, 44, 45, 46, 234,
1078 36, 0, 158, 232, 0, 233, 0, 232, 67, 233,
1079 18, 36, 36, 36, 36, 36, 36, 36, 36, 36,
1080 0, 232, 232, 233, 233, 234, 0, 236, 0, 234,
1081 237, 236, 238, 0, 237, 106, 238, 255, 0, 106,
1082 0, 255, 0, 234, 234, 236, 236, 0, 237, 237,
1083 238, 238, 0, 106, 106, 255, 255, 256, 0, 265,
1084 0, 256, 116, 265, 0, 0, 116, 0, 0, 0,
1085 0, 82, 83, 84, 0, 256, 256, 265, 265, 0,
1086 116, 116, 98, 99, 100, 101, 102, 103, 104, 105,
1087 154, 155, 30, 31, 32, 33, 34, 35, 36, 37,
1088 0, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1089};
1090short yycheck[] = { 25,
1091 12, 38, 159, 41, 58, 42, 41, 164, 38, 44,
1092 40, 41, 42, 41, 44, 58, 44, 41, 40, 38,
1093 44, 40, 41, 42, 41, 44, 61, 44, 58, 59,
1094 61, 61, 59, 61, 125, 171, 58, 63, 61, 58,
1095 59, 38, 61, 40, 41, 42, 38, 44, 40, 41,
1096 42, 123, 44, 224, 261, 81, 59, 140, 61, 261,
1097 91, 91, 88, 59, 61, 360, 226, 224, 40, 61,
1098 60, 292, 91, 61, 44, 19, 44, 38, 235, 40,
1099 41, 42, 61, 44, 59, 242, 61, 289, 114, 59,
1100 116, 117, 44, 123, 91, 178, 123, 58, 59, 91,
1101 61, 61, 38, 91, 41, 41, 42, 44, 38, 192,
1102 40, 41, 42, 38, 44, 40, 59, 42, 61, 38,
1103 123, 40, 41, 42, 61, 44, 60, 123, 58, 59,
1104 91, 61, 123, 58, 59, 161, 59, 308, 59, 58,
1105 59, 20, 61, 330, 331, 124, 333, 334, 123, 261,
1106 38, 308, 40, 123, 42, 91, 44, 125, 40, 171,
1107 171, 91, 123, 38, 261, 40, 41, 42, 112, 44,
1108 58, 59, 91, 125, 469, 258, 58, 261, 290, 261,
1109 123, 293, 353, 58, 59, 269, 61, 323, 67, 261,
1110 235, 282, 283, 123, 261, 221, 353, 242, 123, 359,
1111 123, 292, 123, 360, 123, 38, 290, 218, 290, 42,
1112 59, 368, 261, 123, 38, 38, 91, 228, 261, 42,
1113 123, 165, 261, 290, 261, 58, 59, 41, 38, 400,
1114 40, 261, 42, 261, 44, 290, 290, 61, 261, 261,
1115 427, 290, 261, 400, 293, 40, 261, 44, 58, 59,
1116 289, 41, 289, 291, 297, 298, 291, 261, 261, 289,
1117 60, 291, 59, 291, 261, 60, 296, 291, 91, 261,
1118 289, 261, 291, 217, 291, 272, 273, 274, 275, 276,
1119 277, 278, 279, 280, 281, 282, 283, 284, 167, 261,
1120 123, 59, 289, 290, 291, 292, 59, 261, 61, 291,
1121 261, 262, 263, 264, 265, 266, 267, 268, 269, 270,
1122 271, 323, 469, 38, 38, 360, 40, 42, 42, 261,
1123 290, 261, 38, 368, 261, 289, 42, 62, 289, 290,
1124 291, 261, 262, 263, 264, 265, 266, 267, 268, 269,
1125 270, 271, 261, 262, 263, 264, 265, 266, 267, 268,
1126 269, 270, 271, 38, 291, 58, 59, 42, 61, 289,
1127 123, 291, 293, 294, 38, 290, 40, 91, 42, 41,
1128 289, 44, 291, 261, 262, 263, 264, 265, 266, 267,
1129 268, 269, 270, 271, 58, 59, 261, 262, 263, 264,
1130 265, 266, 267, 268, 269, 270, 271, 43, 52, 40,
1131 38, 289, 290, 44, 42, 282, 283, 433, 59, 62,
1132 61, 125, 60, 61, 289, 61, 291, 58, 59, 125,
1133 123, 75, 38, 45, 469, 41, 42, 125, 261, 262,
1134 263, 264, 265, 266, 267, 268, 269, 270, 271, 61,
1135 62, 58, 468, 91, 38, 40, 164, 261, 42, 123,
1136 40, 261, 60, 61, 61, 62, 289, 290, 272, 273,
1137 274, 275, 276, 277, 278, 279, 280, 281, 282, 283,
1138 284, 261, 123, 230, 41, 91, 290, 291, 292, 289,
1139 282, 283, 272, 273, 274, 275, 276, 277, 278, 279,
1140 280, 281, 282, 283, 284, 265, 40, 91, 261, 33,
1141 290, 44, 292, 37, 38, 261, 40, 40, 42, 43,
1142 44, 45, 230, 47, 38, 81, 59, 244, 42, 40,
1143 44, 41, 88, 241, 76, 261, 60, 61, 62, 81,
1144 286, 287, 288, 296, 290, 59, 261, 262, 263, 264,
1145 265, 266, 267, 268, 269, 270, 271, 44, 114, 306,
1146 260, 117, 261, 44, 324, 40, 108, 91, 261, 44,
1147 94, 126, 59, 58, 289, 322, 261, 91, 59, 339,
1148 340, 298, 58, 58, 59, 261, 261, 262, 263, 264,
1149 265, 266, 267, 268, 269, 270, 271, 40, 44, 307,
1150 124, 44, 126, 296, 294, 295, 38, 261, 40, 326,
1151 42, 328, 125, 126, 289, 58, 59, 364, 41, 366,
1152 261, 282, 283, 313, 261, 41, 58, 374, 270, 271,
1153 261, 292, 269, 350, 262, 263, 264, 265, 266, 267,
1154 268, 269, 270, 271, 261, 261, 406, 261, 356, 286,
1155 287, 288, 123, 290, 41, 296, 416, 41, 289, 261,
1156 407, 125, 126, 410, 282, 283, 61, 40, 415, 40,
1157 61, 44, 93, 44, 41, 61, 61, 42, 261, 61,
1158 440, 441, 61, 61, 444, 58, 59, 58, 59, 272,
1159 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
1160 283, 284, 419, 59, 123, 125, 126, 290, 261, 292,
1161 261, 261, 40, 261, 474, 432, 44, 59, 44, 272,
1162 273, 274, 275, 276, 277, 278, 279, 280, 125, 126,
1163 58, 59, 260, 125, 61, 59, 125, 126, 262, 263,
1164 264, 265, 266, 267, 268, 269, 270, 271, 261, 262,
1165 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
1166 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
1167 283, 284, 61, 286, 287, 288, 289, 290, 61, 292,
1168 293, 294, 125, 126, 297, 298, 299, 300, 301, 302,
1169 303, 304, 59, 41, 291, 44, 41, 261, 262, 263,
1170 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
1171 274, 275, 276, 277, 278, 279, 280, 281, 282, 283,
1172 284, 93, 286, 287, 288, 289, 290, 125, 292, 293,
1173 294, 125, 126, 297, 298, 299, 300, 301, 302, 303,
1174 304, 261, 262, 263, 264, 265, 266, 267, 268, 269,
1175 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
1176 280, 281, 282, 283, 284, 58, 286, 287, 288, 289,
1177 290, 261, 292, 293, 294, 125, 126, 297, 298, 299,
1178 300, 301, 302, 303, 304, 282, 283, 261, 93, 286,
1179 287, 288, 261, 282, 283, 261, 125, 286, 287, 288,
1180 297, 298, 299, 300, 301, 302, 303, 304, 297, 298,
1181 299, 300, 301, 302, 303, 304, 261, 261, 261, 262,
1182 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
1183 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
1184 283, 284, 59, 286, 287, 288, 289, 290, 58, 292,
1185 293, 294, 125, 126, 297, 298, 299, 300, 301, 302,
1186 303, 304, 296, 93, 61, 40, 44, 261, 262, 263,
1187 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
1188 274, 275, 276, 277, 278, 279, 280, 281, 282, 283,
1189 284, 93, 286, 287, 288, 289, 290, 40, 292, 293,
1190 294, 125, 126, 297, 298, 299, 300, 301, 302, 303,
1191 304, 261, 262, 263, 264, 265, 266, 267, 268, 269,
1192 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
1193 280, 281, 282, 283, 284, 93, 286, 287, 288, 289,
1194 290, 41, 292, 293, 294, 125, 126, 297, 298, 299,
1195 300, 301, 302, 303, 304, 262, 263, 264, 265, 266,
1196 267, 268, 269, 270, 271, 41, 258, 40, 125, 126,
1197 125, 44, 59, 123, 125, 123, 125, 126, 305, 306,
1198 307, 308, 309, 310, 291, 58, 59, 125, 261, 262,
1199 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
1200 273, 274, 275, 276, 277, 278, 279, 280, 281, 282,
1201 283, 284, 41, 286, 287, 288, 289, 290, 41, 292,
1202 293, 294, 125, 126, 297, 298, 299, 300, 301, 302,
1203 303, 304, 125, 59, 41, 41, 125, 261, 262, 263,
1204 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
1205 274, 275, 276, 277, 278, 279, 280, 281, 282, 283,
1206 284, 0, 286, 287, 288, 289, 290, 126, 292, 293,
1207 294, 12, 233, 297, 298, 299, 300, 301, 302, 303,
1208 304, 116, 261, 364, 410, 264, 265, 266, 267, 268,
1209 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
1210 279, 280, 282, 283, 303, 19, 286, 287, 288, 40,
1211 19, 372, 164, 44, 365, 92, 73, 297, 298, 299,
1212 300, 301, 302, 303, 304, 282, 283, 58, 59, 286,
1213 287, 288, 471, 282, 283, 19, 459, 286, 287, 288,
1214 297, 298, 299, 300, 301, 302, 303, 304, 297, 298,
1215 299, 300, 301, 302, 303, 304, 261, 468, 40, 108,
1216 142, 189, 44, 187, 261, 178, 258, 272, 273, 274,
1217 275, 276, 277, 278, 279, 280, 58, 59, 420, 282,
1218 283, 341, 268, 286, 287, 288, 421, 422, 423, 424,
1219 425, 426, -1, -1, 297, 298, 299, 300, 301, 302,
1220 303, 304, 261, 262, 263, 264, 265, 266, 267, 268,
1221 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
1222 279, 280, 281, 282, 283, 284, 343, -1, -1, -1,
1223 -1, 290, -1, 292, 261, 262, 263, 264, 265, 266,
1224 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
1225 277, 278, 279, 280, 281, -1, -1, 284, -1, -1,
1226 -1, -1, 289, 290, -1, 292, 293, 294, 261, 262,
1227 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
1228 273, 274, 275, 276, 277, 278, 279, 280, 281, 261,
1229 -1, 284, -1, -1, -1, -1, -1, 290, -1, 292,
1230 272, 273, 274, 275, 276, 277, 278, 279, 280, 281,
1231 261, -1, 284, 40, -1, 40, -1, 44, 290, 44,
1232 292, 272, 273, 274, 275, 276, 277, 278, 279, 280,
1233 -1, 58, 59, 58, 59, 40, -1, 40, -1, 44,
1234 40, 44, 40, -1, 44, 40, 44, 40, -1, 44,
1235 -1, 44, -1, 58, 59, 58, 59, -1, 58, 59,
1236 58, 59, -1, 58, 59, 58, 59, 40, -1, 40,
1237 -1, 44, 40, 44, -1, -1, 44, -1, -1, -1,
1238 -1, 286, 287, 288, -1, 58, 59, 58, 59, -1,
1239 58, 59, 297, 298, 299, 300, 301, 302, 303, 304,
1240 262, 263, 264, 265, 266, 267, 268, 269, 270, 271,
1241 -1, 272, 273, 274, 275, 276, 277, 278, 279, 280,
1242};
1243#define YYFINAL 1
1244#ifndef YYDEBUG
1245#define YYDEBUG 0
1246#endif
1247#define YYMAXTOKEN 310
1248#if YYDEBUG
1249char *yyname[] = {
1250"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1251"'!'",0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,
12520,0,0,0,0,"':'","';'","'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
12530,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
12540,0,0,0,0,0,"'{'","'|'","'}'","'~'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
12550,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
12560,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
12570,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"CHAR_VAL","INT_VAL",
1258"DOUBLE_VAL","STRING","IDENTIFIER","FRIEND","TYPEDEF","AUTO","REGISTER",
1259"STATIC","EXTERN","INLINE","VIRTUAL","CONST","VOLATILE","CHAR","SHORT","INT",
1260"LONG","SIGNED","UNSIGNED","FLOAT","DOUBLE","VOID","ENUM","CLASS","STRUCT",
1261"UNION","ASM","PRIVATE","PROTECTED","PUBLIC","OPERATOR","DBL_COLON",
1262"TRIPLE_DOT","TEMPLATE","NAMESPACE","USING","MUTABLE","THROW","SIGNALS","SLOTS",
1263"Q_OBJECT","Q_PROPERTY","Q_OVERRIDE","Q_CLASSINFO","Q_ENUMS","Q_SETS","READ",
1264"WRITE","STORED","DESIGNABLE","SCRIPTABLE","RESET",
1265};
1266char *yyrule[] = {
1267"$accept : declaration_seq",
1268"declaration_seq :",
1269"declaration_seq : declaration_seq declaration",
1270"declaration : class_def",
1271"declaration : namespace_def",
1272"declaration : namespace_alias_def",
1273"declaration : using_declaration",
1274"declaration : using_directive",
1275"namespace_def : named_namespace_def",
1276"namespace_def : unnamed_namespace_def",
1277"$$1 :",
1278"$$2 :",
1279"named_namespace_def : NAMESPACE IDENTIFIER $$1 '{' $$2 namespace_body '}'",
1280"$$3 :",
1281"$$4 :",
1282"unnamed_namespace_def : NAMESPACE $$3 '{' $$4 namespace_body '}'",
1283"namespace_body : declaration_seq",
1284"namespace_alias_def : NAMESPACE IDENTIFIER '=' complete_class_name ';'",
1285"using_directive : USING NAMESPACE",
1286"using_declaration : USING IDENTIFIER",
1287"using_declaration : USING DBL_COLON",
1288"$$5 :",
1289"class_def : $$5 class_specifier ';'",
1290"class_name : IDENTIFIER",
1291"class_name : template_class_name",
1292"template_class_name : IDENTIFIER '<' template_args '>'",
1293"template_args :",
1294"const_expression :",
1295"def_argument :",
1296"enumerator_expression :",
1297"decl_specifier : storage_class_specifier",
1298"decl_specifier : type_specifier",
1299"decl_specifier : fct_specifier",
1300"decl_specifier : FRIEND",
1301"decl_specifier : TYPEDEF",
1302"decl_specifiers : decl_specs_opt type_name decl_specs_opt",
1303"decl_specs_opt :",
1304"decl_specs_opt : decl_specs",
1305"decl_specs : decl_specifier",
1306"decl_specs : decl_specs decl_specifier",
1307"storage_class_specifier : AUTO",
1308"storage_class_specifier : REGISTER",
1309"storage_class_specifier : STATIC",
1310"storage_class_specifier : EXTERN",
1311"fct_specifier : INLINE",
1312"fct_specifier : VIRTUAL",
1313"type_specifier : CONST",
1314"type_specifier : VOLATILE",
1315"type_name : elaborated_type_specifier",
1316"type_name : complete_class_name",
1317"type_name : simple_type_names",
1318"simple_type_names : simple_type_names simple_type_name",
1319"simple_type_names : simple_type_name",
1320"simple_type_name : CHAR",
1321"simple_type_name : SHORT",
1322"simple_type_name : INT",
1323"simple_type_name : LONG",
1324"simple_type_name : SIGNED",
1325"simple_type_name : UNSIGNED",
1326"simple_type_name : FLOAT",
1327"simple_type_name : DOUBLE",
1328"simple_type_name : VOID",
1329"template_spec : TEMPLATE '<' template_args '>'",
1330"opt_template_spec :",
1331"opt_template_spec : template_spec",
1332"class_key : opt_template_spec CLASS",
1333"class_key : opt_template_spec STRUCT",
1334"complete_class_name : qualified_class_name",
1335"complete_class_name : DBL_COLON qualified_class_name",
1336"qualified_class_name : qualified_class_name DBL_COLON class_name",
1337"qualified_class_name : class_name",
1338"elaborated_type_specifier : class_key IDENTIFIER",
1339"elaborated_type_specifier : ENUM IDENTIFIER",
1340"elaborated_type_specifier : UNION IDENTIFIER",
1341"argument_declaration_list : arg_declaration_list_opt triple_dot_opt",
1342"argument_declaration_list : arg_declaration_list ',' TRIPLE_DOT",
1343"arg_declaration_list_opt :",
1344"arg_declaration_list_opt : arg_declaration_list",
1345"opt_exception_argument :",
1346"opt_exception_argument : argument_declaration",
1347"triple_dot_opt :",
1348"triple_dot_opt : TRIPLE_DOT",
1349"arg_declaration_list : arg_declaration_list ',' argument_declaration",
1350"arg_declaration_list : argument_declaration",
1351"argument_declaration : decl_specifiers abstract_decl_opt",
1352"$$6 :",
1353"argument_declaration : decl_specifiers abstract_decl_opt '=' $$6 def_argument",
1354"argument_declaration : decl_specifiers abstract_decl_opt dname abstract_decl_opt",
1355"$$7 :",
1356"argument_declaration : decl_specifiers abstract_decl_opt dname abstract_decl_opt '=' $$7 def_argument",
1357"abstract_decl_opt :",
1358"abstract_decl_opt : abstract_decl",
1359"abstract_decl : abstract_decl ptr_operator",
1360"$$8 :",
1361"abstract_decl : '[' $$8 const_expression ']'",
1362"$$9 :",
1363"abstract_decl : abstract_decl '[' $$9 const_expression ']'",
1364"abstract_decl : ptr_operator",
1365"abstract_decl : '(' abstract_decl ')'",
1366"declarator : dname",
1367"declarator : declarator ptr_operator",
1368"$$10 :",
1369"declarator : declarator '[' $$10 const_expression ']'",
1370"declarator : '(' declarator ')'",
1371"dname : IDENTIFIER",
1372"fct_decl : '(' argument_declaration_list ')' cv_qualifier_list_opt ctor_initializer_opt exception_spec_opt opt_identifier fct_body_or_semicolon",
1373"fct_name : IDENTIFIER",
1374"fct_name : IDENTIFIER array_decls",
1375"$$11 :",
1376"fct_name : IDENTIFIER '=' $$11 const_expression",
1377"$$12 :",
1378"fct_name : IDENTIFIER array_decls '=' $$12 const_expression",
1379"$$13 :",
1380"array_decls : '[' $$13 const_expression ']'",
1381"$$14 :",
1382"array_decls : array_decls '[' $$14 const_expression ']'",
1383"ptr_operators_opt :",
1384"ptr_operators_opt : ptr_operators",
1385"ptr_operators : ptr_operator",
1386"ptr_operators : ptr_operators ptr_operator",
1387"ptr_operator : '*' cv_qualifier_list_opt",
1388"ptr_operator : '&' cv_qualifier_list_opt",
1389"cv_qualifier_list_opt :",
1390"cv_qualifier_list_opt : cv_qualifier_list",
1391"cv_qualifier_list : cv_qualifier",
1392"cv_qualifier_list : cv_qualifier_list cv_qualifier",
1393"cv_qualifier : CONST",
1394"cv_qualifier : VOLATILE",
1395"fct_body_or_semicolon : ';'",
1396"fct_body_or_semicolon : fct_body",
1397"fct_body_or_semicolon : '=' INT_VAL ';'",
1398"$$15 :",
1399"fct_body : '{' $$15 '}'",
1400"$$16 :",
1401"class_specifier : full_class_head '{' $$16 opt_obj_member_list '}'",
1402"class_specifier : class_head",
1403"class_specifier : class_head '*' IDENTIFIER",
1404"class_specifier : class_head '&' IDENTIFIER",
1405"class_specifier : class_head '(' IDENTIFIER ')'",
1406"class_specifier : template_spec whatever",
1407"whatever : IDENTIFIER",
1408"whatever : simple_type_name",
1409"whatever : type_specifier",
1410"whatever : storage_class_specifier",
1411"whatever : fct_specifier",
1412"class_head : class_key qualified_class_name",
1413"class_head : class_key IDENTIFIER class_name",
1414"full_class_head : class_head opt_base_spec",
1415"nested_class_head : class_key qualified_class_name opt_base_spec",
1416"exception_spec_opt :",
1417"exception_spec_opt : exception_spec",
1418"exception_spec : THROW '(' opt_exception_argument ')'",
1419"ctor_initializer_opt :",
1420"ctor_initializer_opt : ctor_initializer",
1421"ctor_initializer : ':' mem_initializer_list",
1422"mem_initializer_list : mem_initializer",
1423"mem_initializer_list : mem_initializer ',' mem_initializer_list",
1424"$$17 :",
1425"mem_initializer : complete_class_name '(' $$17 const_expression ')'",
1426"opt_base_spec :",
1427"opt_base_spec : base_spec",
1428"opt_obj_member_list :",
1429"opt_obj_member_list : obj_member_list",
1430"obj_member_list : obj_member_list obj_member_area",
1431"obj_member_list : obj_member_area",
1432"qt_access_specifier : access_specifier",
1433"qt_access_specifier : SLOTS",
1434"$$18 :",
1435"obj_member_area : qt_access_specifier $$18 slot_area",
1436"$$19 :",
1437"obj_member_area : SIGNALS $$19 ':' opt_signal_declarations",
1438"obj_member_area : Q_OBJECT",
1439"$$20 :",
1440"$$21 :",
1441"obj_member_area : Q_PROPERTY $$20 '(' property ')' $$21 opt_property_candidates",
1442"$$22 :",
1443"$$23 :",
1444"obj_member_area : Q_OVERRIDE $$22 '(' property ')' $$23 opt_property_candidates",
1445"$$24 :",
1446"$$25 :",
1447"obj_member_area : Q_CLASSINFO $$24 '(' STRING ',' STRING ')' $$25 opt_property_candidates",
1448"$$26 :",
1449"$$27 :",
1450"obj_member_area : Q_ENUMS $$26 '(' qt_enums ')' $$27 opt_property_candidates",
1451"$$28 :",
1452"$$29 :",
1453"obj_member_area : Q_SETS $$28 '(' qt_sets ')' $$29 opt_property_candidates",
1454"slot_area : SIGNALS ':'",
1455"slot_area : SLOTS ':' opt_slot_declarations",
1456"$$30 :",
1457"slot_area : ':' $$30 opt_property_candidates",
1458"slot_area : IDENTIFIER",
1459"opt_property_candidates :",
1460"opt_property_candidates : property_candidate_declarations",
1461"property_candidate_declarations : property_candidate_declarations property_candidate_declaration",
1462"property_candidate_declarations : property_candidate_declaration",
1463"property_candidate_declaration : signal_or_slot",
1464"opt_signal_declarations :",
1465"opt_signal_declarations : signal_declarations",
1466"signal_declarations : signal_declarations signal_declaration",
1467"signal_declarations : signal_declaration",
1468"signal_declaration : signal_or_slot",
1469"opt_slot_declarations :",
1470"opt_slot_declarations : slot_declarations",
1471"slot_declarations : slot_declarations slot_declaration",
1472"slot_declarations : slot_declaration",
1473"slot_declaration : signal_or_slot",
1474"opt_semicolons :",
1475"opt_semicolons : opt_semicolons ';'",
1476"base_spec : ':' base_list",
1477"base_list : base_list ',' base_specifier",
1478"base_list : base_specifier",
1479"qt_macro_name : IDENTIFIER '(' IDENTIFIER ')'",
1480"qt_macro_name : IDENTIFIER '(' simple_type_name ')'",
1481"base_specifier : complete_class_name",
1482"base_specifier : VIRTUAL access_specifier complete_class_name",
1483"base_specifier : VIRTUAL complete_class_name",
1484"base_specifier : access_specifier VIRTUAL complete_class_name",
1485"base_specifier : access_specifier complete_class_name",
1486"base_specifier : qt_macro_name",
1487"base_specifier : VIRTUAL access_specifier qt_macro_name",
1488"base_specifier : VIRTUAL qt_macro_name",
1489"base_specifier : access_specifier VIRTUAL qt_macro_name",
1490"base_specifier : access_specifier qt_macro_name",
1491"access_specifier : PRIVATE",
1492"access_specifier : PROTECTED",
1493"access_specifier : PUBLIC",
1494"operator_name : decl_specs_opt IDENTIFIER ptr_operators_opt",
1495"operator_name : decl_specs_opt simple_type_name ptr_operators_opt",
1496"operator_name : '+'",
1497"operator_name : '-'",
1498"operator_name : '*'",
1499"operator_name : '/'",
1500"operator_name : '%'",
1501"operator_name : '^'",
1502"operator_name : '&'",
1503"operator_name : '|'",
1504"operator_name : '~'",
1505"operator_name : '!'",
1506"operator_name : '='",
1507"operator_name : '<'",
1508"operator_name : '>'",
1509"operator_name : '+' '='",
1510"operator_name : '-' '='",
1511"operator_name : '*' '='",
1512"operator_name : '/' '='",
1513"operator_name : '%' '='",
1514"operator_name : '^' '='",
1515"operator_name : '&' '='",
1516"operator_name : '|' '='",
1517"operator_name : '~' '='",
1518"operator_name : '!' '='",
1519"operator_name : '=' '='",
1520"operator_name : '<' '='",
1521"operator_name : '>' '='",
1522"operator_name : '<' '<'",
1523"operator_name : '>' '>'",
1524"operator_name : '<' '<' '='",
1525"operator_name : '>' '>' '='",
1526"operator_name : '&' '&'",
1527"operator_name : '|' '|'",
1528"operator_name : '+' '+'",
1529"operator_name : '-' '-'",
1530"operator_name : ','",
1531"operator_name : '-' '>' '*'",
1532"operator_name : '-' '>'",
1533"operator_name : '(' ')'",
1534"operator_name : '[' ']'",
1535"opt_virtual :",
1536"opt_virtual : VIRTUAL",
1537"type_and_name : type_name fct_name",
1538"type_and_name : fct_name",
1539"type_and_name : opt_virtual '~' fct_name",
1540"type_and_name : decl_specs type_name decl_specs_opt ptr_operators_opt fct_name",
1541"type_and_name : decl_specs type_name",
1542"type_and_name : type_name ptr_operators fct_name",
1543"type_and_name : type_name decl_specs ptr_operators_opt fct_name",
1544"type_and_name : type_name OPERATOR operator_name",
1545"type_and_name : OPERATOR operator_name",
1546"type_and_name : decl_specs type_name decl_specs_opt ptr_operators_opt OPERATOR operator_name",
1547"type_and_name : type_name ptr_operators OPERATOR operator_name",
1548"type_and_name : type_name decl_specs ptr_operators_opt OPERATOR operator_name",
1549"signal_or_slot : type_and_name fct_decl opt_semicolons",
1550"signal_or_slot : type_and_name opt_bitfield ';' opt_semicolons",
1551"signal_or_slot : type_and_name opt_bitfield ',' member_declarator_list ';' opt_semicolons",
1552"signal_or_slot : enum_specifier opt_identifier ';' opt_semicolons",
1553"signal_or_slot : USING complete_class_name ';' opt_semicolons",
1554"signal_or_slot : USING NAMESPACE complete_class_name ';' opt_semicolons",
1555"signal_or_slot : NAMESPACE IDENTIFIER '{'",
1556"signal_or_slot : nested_class_head ';' opt_semicolons",
1557"$$31 :",
1558"$$32 :",
1559"signal_or_slot : nested_class_head '{' $$31 '}' $$32 ';' opt_semicolons",
1560"member_declarator_list : member_declarator",
1561"member_declarator_list : member_declarator_list ',' member_declarator",
1562"member_declarator : declarator",
1563"$$33 :",
1564"member_declarator : IDENTIFIER ':' $$33 const_expression",
1565"$$34 :",
1566"member_declarator : ':' $$34 const_expression",
1567"opt_bitfield :",
1568"$$35 :",
1569"opt_bitfield : ':' $$35 const_expression",
1570"enum_specifier : ENUM enum_tail",
1571"opt_komma :",
1572"opt_komma : ','",
1573"enum_tail : IDENTIFIER '{' enum_list opt_komma '}'",
1574"enum_tail : '{' enum_list opt_komma '}'",
1575"opt_identifier :",
1576"opt_identifier : IDENTIFIER",
1577"enum_list :",
1578"enum_list : enumerator",
1579"enum_list : enum_list ',' enumerator",
1580"enumerator : IDENTIFIER",
1581"$$36 :",
1582"enumerator : IDENTIFIER '=' $$36 enumerator_expression",
1583"$$37 :",
1584"property : IDENTIFIER IDENTIFIER $$37 prop_statements",
1585"prop_statements :",
1586"prop_statements : READ IDENTIFIER prop_statements",
1587"prop_statements : WRITE IDENTIFIER prop_statements",
1588"prop_statements : RESET IDENTIFIER prop_statements",
1589"prop_statements : STORED IDENTIFIER prop_statements",
1590"prop_statements : DESIGNABLE IDENTIFIER prop_statements",
1591"prop_statements : SCRIPTABLE IDENTIFIER prop_statements",
1592"qt_enums :",
1593"qt_enums : IDENTIFIER qt_enums",
1594"qt_sets :",
1595"qt_sets : IDENTIFIER qt_sets",
1596};
1597#endif
1598#ifdef YYSTACKSIZE
1599#undef YYMAXDEPTH
1600#define YYMAXDEPTH YYSTACKSIZE
1601#else
1602#ifdef YYMAXDEPTH
1603#define YYSTACKSIZE YYMAXDEPTH
1604#else
1605#define YYSTACKSIZE 500
1606#define YYMAXDEPTH 500
1607#endif
1608#endif
1609int yydebug;
1610int yynerrs;
1611int yyerrflag;
1612int yychar;
1613short *yyssp;
1614YYSTYPE *yyvsp;
1615YYSTYPE yyval;
1616YYSTYPE yylval;
1617short yyss[YYSTACKSIZE];
1618YYSTYPE yyvs[YYSTACKSIZE];
1619#define yystacksize YYSTACKSIZE
1620#line 1579 "moc.y"
1621
1622#if defined(Q_OS_WIN32)
1623#include <io.h>
1624#undef isatty
1625extern "C" int hack_isatty( int )
1626{
1627 return 0;
1628}
1629#define isatty hack_isatty
1630#else
1631#include <unistd.h>
1632#endif
1633
1634#include "moc_lex.cpp"
1635
1636void cleanup();
1637QCString combinePath( const char *, const char * );
1638
1639FILE *out; // output file
1640
1641parser_reg::parser_reg() : funcs(TRUE)
1642{
1643 gen_count = 0;
1644 noInclude = FALSE; // no #include <filename>
1645 generatedCode = FALSE; // no code generated
1646 mocError = FALSE; // moc parsing error occurred
1647 hasVariantIncluded = FALSE;
1648}
1649
1650
1651parser_reg::~parser_reg()
1652{
1653 slots.clear();
1654 signals.clear();
1655 propfuncs.clear();
1656 funcs.clear();
1657 infos.clear();
1658 props.clear();
1659 infos.clear();
1660}
1661
1662int yyparse();
1663
1664void replace( char *s, char c1, char c2 );
1665
1666void setDefaultIncludeFile()
1667{
1668 if ( g->includeFiles.isEmpty() ) {
1669 if ( g->includePath.isEmpty() ) {
1670 if ( !g->fileName.isEmpty() && !g->outputFile.isEmpty() ) {
1671 g->includeFiles.append( combinePath(g->fileName, g->outputFile) );
1672 } else {
1673 g->includeFiles.append( g->fileName );
1674 }
1675 } else {
1676 g->includeFiles.append( combinePath(g->fileName, g->fileName) );
1677 }
1678 }
1679}
1680
1681#ifdef Q_CC_MSVC
1682#define ErrorFormatString "%s(%d):"
1683#else
1684#define ErrorFormatString "%s:%d:"
1685#endif
1686
1687#ifndef MOC_MWERKS_PLUGIN
1688int main( int argc, char **argv )
1689{
1690 init();
1691
1692 bool autoInclude = TRUE;
1693 const char *error = 0;
1694 g->qtPath = "";
1695 for ( int n=1; n<argc && error==0; n++ ) {
1696 QCString arg = argv[n];
1697 if ( arg[0] == '-' ) { // option
1698 QCString opt = &arg[1];
1699 if ( opt[0] == 'o' ) { // output redirection
1700 if ( opt[1] == '\0' ) {
1701 if ( !(n < argc-1) ) {
1702 error = "Missing output file name";
1703 break;
1704 }
1705 g->outputFile = argv[++n];
1706 } else
1707 g->outputFile = &opt[1];
1708 } else if ( opt == "i" ) { // no #include statement
1709 g->noInclude = TRUE;
1710 autoInclude = FALSE;
1711 } else if ( opt[0] == 'f' ) { // produce #include statement
1712 g->noInclude = FALSE;
1713 autoInclude = FALSE;
1714 if ( opt[1] ) // -fsomething.h
1715 g->includeFiles.append( &opt[1] );
1716 } else if ( opt == "pch" ) { // produce #include statement for PCH
1717 if ( !(n < argc-1) ) {
1718 error = "Missing name of PCH file";
1719 break;
1720 }
1721 g->pchFile = argv[++n];
1722 } else if ( opt[0] == 'p' ) { // include file path
1723 if ( opt[1] == '\0' ) {
1724 if ( !(n < argc-1) ) {
1725 error = "Missing path name for the -p option.";
1726 break;
1727 }
1728 g->includePath = argv[++n];
1729 } else {
1730 g->includePath = &opt[1];
1731 }
1732 } else if ( opt[0] == 'q' ) { // qt include file path
1733 if ( opt[1] == '\0' ) {
1734 if ( !(n < argc-1) ) {
1735 error = "Missing path name for the -q option.";
1736 break;
1737 }
1738 g->qtPath = argv[++n];
1739 } else {
1740 g->qtPath = &opt[1];
1741 }
1742 replace(g->qtPath.data(),'\\','/');
1743 if ( g->qtPath.right(1) != "/" )
1744 g->qtPath += '/';
1745 } else if ( opt == "v" ) { // version number
1746 fprintf( stderr, "Qt Meta Object Compiler version %d"
1747 " (Qt %s)\n", formatRevision,
1748 QT_VERSION_STR );
1749 cleanup();
1750 return 1;
1751 } else if ( opt == "k" ) { // stop on errors
1752 errorControl = TRUE;
1753 } else if ( opt == "nw" ) { // don't display warnings
1754 displayWarnings = FALSE;
1755 } else if ( opt == "ldbg" ) { // lex debug output
1756 lexDebug = TRUE;
1757 } else if ( opt == "ydbg" ) { // yacc debug output
1758 yydebug = TRUE;
1759 } else {
1760 error = "Invalid argument";
1761 }
1762 } else {
1763 if ( !g->fileName.isNull() ) // can handle only one file
1764 error = "Too many input files specified";
1765 else
1766 g->fileName = arg.copy();
1767 }
1768 }
1769
1770 if ( autoInclude ) {
1771 int ppos = g->fileName.findRev('.');
1772 if ( ppos != -1 && tolower( g->fileName[ppos + 1] ) == 'h' )
1773 g->noInclude = FALSE;
1774 else
1775 g->noInclude = TRUE;
1776 }
1777 setDefaultIncludeFile();
1778
1779 if ( g->fileName.isNull() && !error ) {
1780 g->fileName = "standard input";
1781 yyin = stdin;
1782 } else if ( argc < 2 || error ) { // incomplete/wrong args
1783 fprintf( stderr, "Qt meta object compiler\n" );
1784 if ( error )
1785 fprintf( stderr, "moc: %s\n", error );
1786 fprintf( stderr, "Usage: moc [options] <header-file>\n"
1787 "\t-o file Write output to file rather than stdout\n"
1788 "\t-f[file] Force #include, optional file name\n"
1789 "\t-p path Path prefix for included file\n"
1790 "\t-i Do not generate an #include statement\n"
1791 "\t-k Do not stop on errors\n"
1792 "\t-nw Do not display warnings\n"
1793 "\t-v Display version of moc\n" );
1794 cleanup();
1795 return 1;
1796 } else {
1797 yyin = fopen( (const char *)g->fileName, "r" );
1798 if ( !yyin ) {
1799 fprintf( stderr, "moc: %s: No such file\n", (const char*)g->fileName);
1800 cleanup();
1801 return 1;
1802 }
1803 }
1804 if ( !g->outputFile.isEmpty() ) { // output file specified
1805 out = fopen( (const char *)g->outputFile, "w" ); // create output file
1806 if ( !out ) {
1807 fprintf( stderr, "moc: Cannot create %s\n",
1808 (const char*)g->outputFile );
1809 cleanup();
1810 return 1;
1811 }
1812 } else { // use stdout
1813 out = stdout;
1814 }
1815 yyparse();
1816 fclose( yyin );
1817 if ( !g->outputFile.isNull() )
1818 fclose( out );
1819
1820 if ( !g->generatedCode && displayWarnings && !g->mocError ) {
1821 fprintf( stderr, ErrorFormatString" Warning: %s\n", g->fileName.data(), 0,
1822 "No relevant classes found. No output generated." );
1823 }
1824
1825 int ret = g->mocError ? 1 : 0;
1826 cleanup();
1827 return ret;
1828}
1829#else
1830bool qt_is_gui_used = FALSE;
1831#include <ctype.h>
1832#include <stdio.h>
1833#include <string.h>
1834#ifdef Q_OS_MAC9
1835# include <Files.h>
1836# include <Strings.h>
1837# include <Errors.h>
1838# include "Aliases.h"
1839#endif
1840#include "CWPluginErrors.h"
1841#include <CWPlugins.h>
1842#include "DropInCompilerLinker.h"
1843#include <stat.h>
1844
1845const unsigned char *p_str(const char *, int =-1);
1846
1847CWPluginContext g_ctx;
1848
1849moc_status do_moc( CWPluginContext ctx, const QCString &fin, const QCString &fout, CWFileSpec *dspec, bool i)
1850{
1851 init();
1852
1853 g_ctx = ctx;
1854 g->noInclude = i;
1855 g->fileName = fin;
1856 g->outputFile = fout;
1857
1858 setDefaultIncludeFile();
1859
1860 CWFileInfo fi;
1861 memset(&fi, 0, sizeof(fi));
1862 fi.fullsearch = TRUE;
1863 fi.dependencyType = cwNormalDependency;
1864 fi.isdependentoffile = kCurrentCompiledFile;
1865 if(CWFindAndLoadFile( ctx, fin.data(), &fi) != cwNoErr) {
1866 cleanup();
1867 return moc_no_source;
1868 }
1869
1870 if(dspec) {
1871 memcpy(dspec, &fi.filespec, sizeof(fi.filespec));
1872 const unsigned char *f = p_str(fout.data());
1873 memcpy(dspec->name, f, f[0]+1);
1874 free(f);
1875 }
1876 buf_size_total = fi.filedatalength;
1877 buf_buffer = fi.filedata;
1878
1879 QCString path("");
1880 AliasHandle alias;
1881 Str63 str;
1882 AliasInfoType x = 1;
1883 char tmp[sizeof(Str63)+2];
1884 if(NewAlias( NULL, &fi.filespec, &alias) != noErr) {
1885 cleanup();
1886 return moc_general_error;
1887 }
1888 for(;;) {
1889 GetAliasInfo(alias, x++, str);
1890 if(!str[0])
1891 break;
1892 strncpy((char *)tmp, (const char *)str+1, str[0]);
1893 tmp[str[0]] = '\0';
1894 path.prepend(":");
1895 path.prepend((char *)tmp);
1896 }
1897 path.prepend("MacOS 9:"); //FIXME
1898
1899 QString inpath = path + fin, outpath = path + fout;
1900 struct stat istat, ostat;
1901 if(stat(inpath, &istat) == -1) {
1902 cleanup();
1903 return moc_no_source;
1904 }
1905 if(stat(outpath, &ostat) == 0 && istat.st_mtime < ostat.st_mtime) {
1906 cleanup();
1907 return moc_not_time;
1908 }
1909
1910 unlink(outpath.data());
1911 out = fopen(outpath.data(), "w+");
1912 if(!out) {
1913 cleanup();
1914 return moc_general_error;
1915 }
1916
1917 yyparse();
1918 if(out != stdout)
1919 fclose(out);
1920
1921 if(g->mocError || !g->generatedCode) {
1922 unlink(outpath.data());
1923 moc_status ret = !g->generatedCode ? moc_no_qobject : moc_parse_error;
1924 cleanup();
1925 return ret;
1926 }
1927
1928 cleanup();
1929 return moc_success;
1930}
1931#endif
1932void replace( char *s, char c1, char c2 )
1933{
1934 if ( !s )
1935 return;
1936 while ( *s ) {
1937 if ( *s == c1 )
1938 *s = c2;
1939 s++;
1940 }
1941}
1942
1943/*
1944 This function looks at two file names and returns the name of the
1945 infile with a path relative to outfile.
1946
1947 Examples:
1948
1949 /tmp/abc, /tmp/bcd -> abc
1950 xyz/a/bc, xyz/b/ac -> ../a/bc
1951 /tmp/abc, xyz/klm -> /tmp/abc
1952 */
1953
1954QCString combinePath( const char *infile, const char *outfile )
1955{
1956 QFileInfo inFileInfo( QDir::current(), QFile::decodeName(infile) );
1957 QFileInfo outFileInfo( QDir::current(), QFile::decodeName(outfile) );
1958 int numCommonComponents = 0;
1959
1960 QStringList inSplitted =
1961 QStringList::split( '/', inFileInfo.dir().canonicalPath(), TRUE );
1962 QStringList outSplitted =
1963 QStringList::split( '/', outFileInfo.dir().canonicalPath(), TRUE );
1964
1965 while ( !inSplitted.isEmpty() && !outSplitted.isEmpty() &&
1966 inSplitted.first() == outSplitted.first() ) {
1967 inSplitted.remove( inSplitted.begin() );
1968 outSplitted.remove( outSplitted.begin() );
1969 numCommonComponents++;
1970 }
1971
1972 if ( numCommonComponents < 2 ) {
1973 /*
1974 The paths don't have the same drive, or they don't have the
1975 same root directory. Use an absolute path.
1976 */
1977 return QFile::encodeName( inFileInfo.absFilePath() );
1978 } else {
1979 /*
1980 The paths have something in common. Use a path relative to
1981 the output file.
1982 */
1983 while ( !outSplitted.isEmpty() ) {
1984 outSplitted.remove( outSplitted.begin() );
1985 inSplitted.prepend( ".." );
1986 }
1987 inSplitted.append( inFileInfo.fileName() );
1988 return QFile::encodeName( inSplitted.join("/") );
1989 }
1990}
1991
1992
1993#define getenv hack_getenv // workaround for byacc
1994char *getenv() { return 0; }
1995char *getenv( const char * ) { return 0; }
1996
1997void init() // initialize
1998{
1999 BEGIN OUTSIDE;
2000 if(g)
2001 delete g;
2002 g = new parser_reg;
2003 lineNo = 1;
2004 skipClass = FALSE;
2005 skipFunc = FALSE;
2006 tmpArgList = new ArgList;
2007 tmpFunc = new Function;
2008 tmpEnum = new Enum;
2009
2010#ifdef MOC_MWERKS_PLUGIN
2011 buf_buffer = NULL;
2012 buf_index = 0;
2013 buf_size_total = 0;
2014#endif
2015}
2016
2017void cleanup()
2018{
2019 delete g;
2020 g = NULL;
2021
2022#ifdef MOC_MWERKS_PLUGIN
2023 if(buf_buffer && g_ctx)
2024 CWReleaseFileText(g_ctx, buf_buffer);
2025#endif
2026}
2027
2028void initClass() // prepare for new class
2029{
2030 tmpAccess = Private;
2031 subClassPerm = Private;
2032 Q_OBJECTdetected = FALSE;
2033 Q_PROPERTYdetected = FALSE;
2034 skipClass = FALSE;
2035 templateClass = FALSE;
2036 g->slots.clear();
2037 g->signals.clear();
2038 g->propfuncs.clear();
2039 g->enums.clear();
2040 g->funcs.clear();
2041 g->props.clear();
2042 g->infos.clear();
2043 g->qtSets.clear();
2044 g->qtEnums.clear();
2045 g->multipleSuperClasses.clear();
2046}
2047
2048struct NamespaceInfo
2049{
2050 QCString name;
2051 int pLevelOnEntering; // Parenthesis level on entering the namespace
2052 QDict<char> definedClasses; // Classes defined in the namespace
2053};
2054
2055QPtrList<NamespaceInfo> namespaces;
2056
2057void enterNameSpace( const char *name ) // prepare for new class
2058{
2059 static bool first = TRUE;
2060 if ( first ) {
2061 namespaces.setAutoDelete( TRUE );
2062 first = FALSE;
2063 }
2064
2065 NamespaceInfo *tmp = new NamespaceInfo;
2066 if ( name )
2067 tmp->name = name;
2068 tmp->pLevelOnEntering = namespacePLevel;
2069 namespaces.append( tmp );
2070}
2071
2072void leaveNameSpace() // prepare for new class
2073{
2074 NamespaceInfo *tmp = namespaces.last();
2075 namespacePLevel = tmp->pLevelOnEntering;
2076 namespaces.remove();
2077}
2078
2079QCString nameQualifier()
2080{
2081 QPtrListIterator<NamespaceInfo> iter( namespaces );
2082 NamespaceInfo *tmp;
2083 QCString qualifier = "";
2084 for( ; (tmp = iter.current()) ; ++iter ) {
2085 if ( !tmp->name.isNull() ) { // If not unnamed namespace
2086 qualifier += tmp->name;
2087 qualifier += "::";
2088 }
2089 }
2090 return qualifier;
2091}
2092
2093int openNameSpaceForMetaObject( FILE *out )
2094{
2095 int levels = 0;
2096 QPtrListIterator<NamespaceInfo> iter( namespaces );
2097 NamespaceInfo *tmp;
2098 QCString indent = "";
2099 for( ; (tmp = iter.current()) ; ++iter ) {
2100 if ( !tmp->name.isNull() ) { // If not unnamed namespace
2101 fprintf( out, "%snamespace %s {\n", (const char *)indent,
2102 (const char *) tmp->name );
2103 indent += " ";
2104 levels++;
2105 }
2106 }
2107 QCString nm = g->className;
2108 int pos;
2109 while( (pos = nm.find( "::" )) != -1 ) {
2110 QCString spaceName = nm.left( pos );
2111 nm = nm.right( nm.length() - pos - 2 );
2112 if ( !spaceName.isEmpty() ) {
2113 fprintf( out, "%snamespace %s {\n", (const char *)indent,
2114 (const char *) spaceName );
2115 indent += " ";
2116 levels++;
2117 }
2118 }
2119 return levels;
2120}
2121
2122void closeNameSpaceForMetaObject( FILE *out, int levels )
2123{
2124 int i;
2125 for( i = 0 ; i < levels ; i++ )
2126 fprintf( out, "}" );
2127 if ( levels )
2128 fprintf( out, "\n" );
2129
2130}
2131
2132void selectOutsideClassState()
2133{
2134 if ( namespaces.count() == 0 )
2135 BEGIN OUTSIDE;
2136 else
2137 BEGIN IN_NAMESPACE;
2138}
2139
2140void registerClassInNamespace()
2141{
2142 if ( namespaces.count() == 0 )
2143 return;
2144 namespaces.last()->definedClasses.insert((const char *)g->className,(char*)1);
2145}
2146
2147//
2148// Remove white space from SIGNAL and SLOT names.
2149// This function has been copied from qobject.cpp.
2150//
2151
2152inline bool isIdentChar( char x )
2153{ // Avoid bug in isalnum
2154 return x == '_' || (x >= '0' && x <= '9') ||
2155 (x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z');
2156}
2157
2158inline bool isSpace( char x )
2159{
2160#if defined(Q_CC_BOR)
2161 /*
2162 Borland C++ 4.5 has a weird isspace() bug.
2163 isspace() usually works, but not here.
2164 This implementation is sufficient for our internal use: rmWS()
2165 */
2166 return (uchar) x <= 32;
2167#else
2168 return isspace( (uchar) x );
2169#endif
2170}
2171
2172static QCString rmWS( const char *src )
2173{
2174 QCString result( qstrlen(src)+1 );
2175 char *d = result.data();
2176 char *s = (char *)src;
2177 char last = 0;
2178 while( *s && isSpace(*s) ) // skip leading space
2179 s++;
2180 while ( *s ) {
2181 while ( *s && !isSpace(*s) )
2182 last = *d++ = *s++;
2183 while ( *s && isSpace(*s) )
2184 s++;
2185 if ( *s && isIdentChar(*s) && isIdentChar(last) )
2186 last = *d++ = ' ';
2187 }
2188 result.truncate( (int)(d - result.data()) );
2189 return result;
2190}
2191
2192
2193void initExpression()
2194{
2195 g->tmpExpression = "";
2196}
2197
2198void addExpressionString( const char *s )
2199{
2200 g->tmpExpression += s;
2201}
2202
2203void addExpressionChar( const char c )
2204{
2205 g->tmpExpression += c;
2206}
2207
2208void yyerror( const char *msg ) // print yacc error message
2209{
2210 g->mocError = TRUE;
2211#ifndef MOC_MWERKS_PLUGIN
2212 fprintf( stderr, ErrorFormatString" Error: %s\n", g->fileName.data(), lineNo, msg );
2213#else
2214 char msg2[200];
2215 sprintf(msg2, ErrorFormatString" Error: %s", g->fileName.data(), lineNo, msg);
2216 CWReportMessage(g_ctx, NULL, msg2, NULL, messagetypeError, 0);
2217#endif
2218 if ( errorControl ) {
2219 if ( !g->outputFile.isEmpty() && yyin && fclose(yyin) == 0 )
2220 remove( g->outputFile );
2221 exit( -1 );
2222 }
2223}
2224
2225void moc_err( const char *s )
2226{
2227 yyerror( s );
2228}
2229
2230void moc_err( const char *s1, const char *s2 )
2231{
2232 static char tmp[1024];
2233 sprintf( tmp, s1, s2 );
2234 yyerror( tmp );
2235}
2236
2237void moc_warn( const char *msg )
2238{
2239 if ( displayWarnings )
2240 fprintf( stderr, ErrorFormatString" Warning: %s\n", g->fileName.data(), lineNo, msg);
2241}
2242
2243void moc_warn( char *s1, char *s2 )
2244{
2245 static char tmp[1024];
2246 sprintf( tmp, s1, s2 );
2247 if ( displayWarnings )
2248 fprintf( stderr, ErrorFormatString" Warning: %s\n", g->fileName.data(), lineNo, tmp);
2249}
2250
2251void func_warn( const char *msg )
2252{
2253 if ( !suppress_func_warn )
2254 moc_warn( msg );
2255 skipFunc = TRUE;
2256}
2257
2258void operatorError()
2259{
2260 if ( !suppress_func_warn )
2261 moc_warn("Operator functions cannot be signals or slots.");
2262 skipFunc = TRUE;
2263}
2264
2265#ifndef yywrap
2266int yywrap() // more files?
2267{
2268 return 1; // end of file
2269}
2270#endif
2271
2272char *stradd( const char *s1, const char *s2 ) // adds two strings
2273{
2274 char *n = new char[qstrlen(s1)+qstrlen(s2)+1];
2275 qstrcpy( n, s1 );
2276 strcat( n, s2 );
2277 return n;
2278}
2279
2280char *stradd( const char *s1, const char *s2, const char *s3 )// adds 3 strings
2281{
2282 char *n = new char[qstrlen(s1)+qstrlen(s2)+qstrlen(s3)+1];
2283 qstrcpy( n, s1 );
2284 strcat( n, s2 );
2285 strcat( n, s3 );
2286 return n;
2287}
2288
2289char *stradd( const char *s1, const char *s2,
2290 const char *s3, const char *s4 )// adds 4 strings
2291{
2292 char *n = new char[qstrlen(s1)+qstrlen(s2)+qstrlen(s3)+qstrlen(s4)+1];
2293 qstrcpy( n, s1 );
2294 strcat( n, s2 );
2295 strcat( n, s3 );
2296 strcat( n, s4 );
2297 return n;
2298}
2299
2300
2301char *straddSpc( const char *s1, const char *s2 )
2302{
2303 char *n = new char[qstrlen(s1)+qstrlen(s2)+2];
2304 qstrcpy( n, s1 );
2305 strcat( n, " " );
2306 strcat( n, s2 );
2307 return n;
2308}
2309
2310char *straddSpc( const char *s1, const char *s2, const char *s3 )
2311{
2312 char *n = new char[qstrlen(s1)+qstrlen(s2)+qstrlen(s3)+3];
2313 qstrcpy( n, s1 );
2314 strcat( n, " " );
2315 strcat( n, s2 );
2316 strcat( n, " " );
2317 strcat( n, s3 );
2318 return n;
2319}
2320
2321char *straddSpc( const char *s1, const char *s2,
2322 const char *s3, const char *s4 )
2323{
2324 char *n = new char[qstrlen(s1)+qstrlen(s2)+qstrlen(s3)+qstrlen(s4)+4];
2325 qstrcpy( n, s1 );
2326 strcat( n, " " );
2327 strcat( n, s2 );
2328 strcat( n, " " );
2329 strcat( n, s3 );
2330 strcat( n, " " );
2331 strcat( n, s4 );
2332 return n;
2333}
2334
2335// Generate C++ code for building member function table
2336
2337
2338/*
2339 We call B::qt_invoke() rather than A::B::qt_invoke() to
2340 work around a bug in MSVC 6. The bug occurs if the
2341 super-class is in a namespace and the sub-class isn't.
2342
2343 Exception: If the superclass has the same name as the subclass, we
2344 want non-MSVC users to have a working generated files.
2345*/
2346QCString purestSuperClassName()
2347{
2348 QCString sc = g->superClassName;
2349 QCString c = g->className;
2350 /*
2351 Make sure qualified template arguments (e.g., foo<bar::baz>)
2352 don't interfere.
2353 */
2354 int pos = sc.findRev( "::", sc.find( '<' ) );
2355 if ( pos != -1 ) {
2356 sc = sc.right( sc.length() - pos - 2 );
2357 pos = c.findRev( "::" );
2358 if ( pos != -1 )
2359 c = c.right( c.length() - pos - 2 );
2360 if ( sc == c )
2361 sc = g->superClassName;
2362 }
2363 return sc;
2364}
2365
2366QCString qualifiedClassName()
2367{
2368 return nameQualifier() + g->className;
2369}
2370
2371const int Slot_Num = 1;
2372const int Signal_Num = 2;
2373const int Prop_Num = 3;
2374
2375void generateFuncs( FuncList *list, const char *functype, int num )
2376{
2377 Function *f;
2378 for ( f=list->first(); f; f=list->next() ) {
2379 bool hasReturnValue = f->type != "void" && (validUType( f->type ) || isVariantType( f->type) );
2380
2381 if ( hasReturnValue || !f->args->isEmpty() ) {
2382 fprintf( out, " static const QUParameter param_%s_%d[] = {\n", functype, list->at() );
2383 if ( hasReturnValue ) {
2384 if ( validUType( f->type ) )
2385 fprintf( out, "\t{ 0, &static_QUType_%s, %s, QUParameter::Out }", uType(f->type).data(), uTypeExtra(f->type).data() );
2386 else
2387 fprintf( out, "\t{ 0, &static_QUType_QVariant, %s, QUParameter::Out }", uTypeExtra(f->type).data() );
2388 if ( !f->args->isEmpty() )
2389 fprintf( out, ",\n" );
2390 }
2391 Argument* a = f->args->first();
2392 while ( a ) {
2393 QCString type = a->leftType + ' ' + a->rightType;
2394 type = type.simplifyWhiteSpace();
2395 if( a->name.isEmpty() )
2396 fprintf( out, "\t{ 0, &static_QUType_%s, %s, QUParameter::%s }",
2397 uType( type ).data(), uTypeExtra( type ).data(),
2398 isInOut( type ) ? "InOut" : "In" );
2399 else
2400 fprintf( out, "\t{ \"%s\", &static_QUType_%s, %s, QUParameter::%s }",
2401 a->name.data(), uType( type ).data(), uTypeExtra( type ).data(),
2402 isInOut( type ) ? "InOut" : "In" );
2403 a = f->args->next();
2404 if ( a )
2405 fprintf( out, ",\n" );
2406 }
2407 fprintf( out, "\n };\n");
2408 }
2409
2410 fprintf( out, " static const QUMethod %s_%d = {", functype, list->at() );
2411 int n = f->args->count();
2412 if ( hasReturnValue )
2413 n++;
2414 fprintf( out, "\"%s\", %d,", f->name.data(), n );
2415 if ( n )
2416 fprintf( out, " param_%s_%d };\n", functype, list->at() );
2417 else
2418 fprintf( out, " 0 };\n" );
2419
2420 QCString typstr = "";
2421 int count = 0;
2422 Argument *a = f->args->first();
2423 while ( a ) {
2424 if ( !a->leftType.isEmpty() || ! a->rightType.isEmpty() ) {
2425 if ( count++ )
2426 typstr += ",";
2427 typstr += a->leftType;
2428 typstr += a->rightType;
2429 }
2430 a = f->args->next();
2431 }
2432 f->signature = f->name;
2433 f->signature += "(";
2434 f->signature += typstr;
2435 f->signature += ")";
2436 }
2437 if ( list->count() ) {
2438 fprintf(out," static const QMetaData %s_tbl[] = {\n", functype );
2439 f = list->first();
2440 while ( f ) {
2441 fprintf( out, "\t{ \"%s\",", f->signature.data() );
2442 fprintf( out, " &%s_%d,", functype, list->at() );
2443 fprintf( out, " QMetaData::%s }", f->accessAsString() );
2444 f = list->next();
2445 if ( f )
2446 fprintf( out, ",\n");
2447 }
2448 fprintf( out, "\n };\n" );
2449 }
2450}
2451
2452
2453int enumIndex( const char* type )
2454{
2455 int index = 0;
2456 for( QPtrListIterator<Enum> lit( g->enums ); lit.current(); ++lit ) {
2457 if ( lit.current()->name == type )
2458 return index;
2459 index++;
2460 }
2461 return -1;
2462}
2463
2464bool isEnumType( const char* type )
2465{
2466 return enumIndex( type ) >= 0 || ( g->qtEnums.contains( type ) || g->qtSets.contains( type ) );
2467}
2468
2469bool isPropertyType( const char* type )
2470{
2471 if ( isVariantType( type ) )
2472 return TRUE;
2473
2474 return isEnumType( type );
2475}
2476
2477int generateEnums()
2478{
2479 if ( g->enums.count() == 0 )
2480 return 0;
2481
2482 fprintf( out, "#ifndef QT_NO_PROPERTIES\n" );
2483 int i = 0;
2484 for ( QPtrListIterator<Enum> it( g->enums ); it.current(); ++it, ++i ) {
2485 fprintf( out, " static const QMetaEnum::Item enum_%i[] = {\n", i );
2486 int k = 0;
2487 for( QStrListIterator eit( *it.current() ); eit.current(); ++eit, ++k ) {
2488 if ( k )
2489 fprintf( out, ",\n" );
2490 fprintf( out, "\t{ \"%s\", (int) %s::%s }", eit.current(), (const char*) g->className, eit.current() );
2491 }
2492 fprintf( out, "\n };\n" );
2493 }
2494 fprintf( out, " static const QMetaEnum enum_tbl[] = {\n" );
2495 i = 0;
2496 for ( QPtrListIterator<Enum> it2( g->enums ); it2.current(); ++it2, ++i ) {
2497 if ( i )
2498 fprintf( out, ",\n" );
2499 fprintf( out, "\t{ \"%s\", %u, enum_%i, %s }",
2500 (const char*)it2.current()->name,
2501 it2.current()->count(),
2502 i,
2503 it2.current()->set ? "TRUE" : "FALSE" );
2504 }
2505 fprintf( out, "\n };\n" );
2506 fprintf( out, "#endif // QT_NO_PROPERTIES\n" );
2507
2508 return g->enums.count();
2509}
2510
2511int generateProps()
2512{
2513 //
2514 // Resolve and verify property access functions
2515 //
2516 for( QPtrListIterator<Property> it( g->props ); it.current(); ) {
2517 Property* p = it.current();
2518 ++it;
2519
2520 // verify get function
2521 if ( !p->get.isEmpty() ) {
2522 FuncList candidates = g->propfuncs.find( p->get );
2523 for ( Function* f = candidates.first(); f; f = candidates.next() ) {
2524 if ( f->qualifier != "const" ) // get functions must be const
2525 continue;
2526 if ( f->args && !f->args->isEmpty() ) // and must not take any arguments
2527 continue;
2528 QCString tmp = f->type;
2529 Property::Specification spec = Property::Unspecified;
2530 if ( p->type == "QCString" && (tmp == "const char*" || tmp == "const char *" ) ) {
2531 tmp = "QCString";
2532 spec = Property::ConstCharStar;
2533 } else if ( tmp.right(1) == "&" ) {
2534 tmp = tmp.left( tmp.length() - 1 );
2535 spec = Property::Reference;
2536 } else if ( tmp.right(1) == "*" ) {
2537 tmp = tmp.left( tmp.length() - 1 );
2538 spec = Property::Pointer;
2539 } else {
2540 spec = Property::Class;
2541 }
2542 if ( tmp.left(6) == "const " )
2543 tmp = tmp.mid( 6, tmp.length() - 6 );
2544 tmp = tmp.simplifyWhiteSpace();
2545 if ( p->type == tmp ) {
2546 // If it is an enum then it may not be a set
2547 bool ok = TRUE;
2548 for( QPtrListIterator<Enum> lit( g->enums ); lit.current(); ++lit )
2549 if ( lit.current()->name == p->type && lit.current()->set )
2550 ok = FALSE;
2551 if ( !ok ) continue;
2552 p->gspec = spec;
2553 p->getfunc = f;
2554 p->oredEnum = 0;
2555 break;
2556 }
2557 else if ( !isVariantType( p->type ) ) {
2558 if ( tmp == "int" || tmp == "uint" || tmp == "unsigned int" ) {
2559 // Test whether the enum is really a set (unfortunately we don't know enums of super classes)
2560 bool ok = TRUE;
2561 for( QPtrListIterator<Enum> lit( g->enums ); lit.current(); ++lit )
2562 if ( lit.current()->name == p->type && !lit.current()->set )
2563 ok = FALSE;
2564 if ( !ok ) continue;
2565 p->gspec = spec;
2566 p->getfunc = f;
2567 p->oredEnum = 1;
2568 p->enumgettype = tmp;
2569 }
2570 }
2571 }
2572 if ( p->getfunc == 0 ) {
2573 if ( displayWarnings ) {
2574
2575 // Is the type a set, that means, mentioned in Q_SETS?
2576 bool set = FALSE;
2577 for( QPtrListIterator<Enum> lit( g->enums ); lit.current(); ++lit )
2578 if ( lit.current()->name == p->type && lit.current()->set )
2579 set = TRUE;
2580
2581 fprintf( stderr, ErrorFormatString" Warning: Property '%s' not available.\n",
2582 g->fileName.data(), p->lineNo, (const char*) p->name );
2583 fprintf( stderr, " Have been looking for public get functions \n");
2584 if ( !set ) {
2585 fprintf( stderr,
2586 " %s %s() const\n"
2587 " %s& %s() const\n"
2588 " const %s& %s() const\n"
2589 " %s* %s() const\n",
2590 (const char*) p->type, (const char*) p->get,
2591 (const char*) p->type, (const char*) p->get,
2592 (const char*) p->type, (const char*) p->get,
2593 (const char*) p->type, (const char*) p->get );
2594 }
2595 if ( set || !isPropertyType( p->type ) ) {
2596 fprintf( stderr,
2597 " int %s() const\n"
2598 " uint %s() const\n"
2599 " unsigned int %s() const\n",
2600 (const char*) p->get,
2601 (const char*) p->get,
2602 (const char*) p->get );
2603 }
2604 if ( p->type == "QCString" )
2605 fprintf( stderr, " const char* %s() const\n",
2606 (const char*)p->get );
2607
2608 if ( candidates.isEmpty() ) {
2609 fprintf( stderr, " but found nothing.\n");
2610 } else {
2611 fprintf( stderr, " but only found the mismatching candidate(s)\n");
2612 for ( Function* f = candidates.first(); f; f = candidates.next() ) {
2613 QCString typstr = "";
2614 Argument *a = f->args->first();
2615 int count = 0;
2616 while ( a ) {
2617 if ( !a->leftType.isEmpty() || ! a->rightType.isEmpty() ) {
2618 if ( count++ )
2619 typstr += ",";
2620 typstr += a->leftType;
2621 typstr += a->rightType;
2622 }
2623 a = f->args->next();
2624 }
2625 fprintf( stderr, " %s:%d: %s %s(%s) %s\n", g->fileName.data(), f->lineNo,
2626 (const char*) f->type,(const char*) f->name, (const char*) typstr,
2627 f->qualifier.isNull()?"":(const char*) f->qualifier );
2628 }
2629 }
2630 }
2631 }
2632 }
2633
2634 // verify set function
2635 if ( !p->set.isEmpty() ) {
2636 FuncList candidates = g->propfuncs.find( p->set );
2637 for ( Function* f = candidates.first(); f; f = candidates.next() ) {
2638 if ( !f->args || f->args->isEmpty() )
2639 continue;
2640 QCString tmp = f->args->first()->leftType;
2641 tmp = tmp.simplifyWhiteSpace();
2642 Property::Specification spec = Property::Unspecified;
2643 if ( tmp.right(1) == "&" ) {
2644 tmp = tmp.left( tmp.length() - 1 );
2645 spec = Property::Reference;
2646 }
2647 else {
2648 spec = Property::Class;
2649 }
2650 if ( p->type == "QCString" && (tmp == "const char*" || tmp == "const char *" ) ) {
2651 tmp = "QCString";
2652 spec = Property::ConstCharStar;
2653 }
2654 if ( tmp.left(6) == "const " )
2655 tmp = tmp.mid( 6, tmp.length() - 6 );
2656 tmp = tmp.simplifyWhiteSpace();
2657
2658 if ( p->type == tmp && f->args->count() == 1 ) {
2659 // If it is an enum then it may not be a set
2660 if ( p->oredEnum == 1 )
2661 continue;
2662 bool ok = TRUE;
2663 for( QPtrListIterator<Enum> lit( g->enums ); lit.current(); ++lit )
2664 if ( lit.current()->name == p->type && lit.current()->set )
2665 ok = FALSE;
2666 if ( !ok ) continue;
2667 p->sspec = spec;
2668 p->setfunc = f;
2669 p->oredEnum = 0;
2670 break;
2671 } else if ( !isVariantType( p->type ) && f->args->count() == 1 ) {
2672 if ( tmp == "int" || tmp == "uint" || tmp == "unsigned int" ) {
2673 if ( p->oredEnum == 0 )
2674 continue;
2675 // Test wether the enum is really a set (unfortunately we don't know enums of super classes)
2676 bool ok = TRUE;
2677 for( QPtrListIterator<Enum> lit( g->enums ); lit.current(); ++lit )
2678 if ( lit.current()->name == p->type && !lit.current()->set )
2679 ok = FALSE;
2680 if ( !ok ) continue;
2681 p->sspec = spec;
2682 p->setfunc = f;
2683 p->oredEnum = 1;
2684 p->enumsettype = tmp;
2685 }
2686 }
2687 }
2688 if ( p->setfunc == 0 ) {
2689 if ( displayWarnings ) {
2690
2691 // Is the type a set, that means, mentioned in Q_SETS ?
2692 bool set = FALSE;
2693 for( QPtrListIterator<Enum> lit( g->enums ); lit.current(); ++lit )
2694 if ( lit.current()->name == p->type && lit.current()->set )
2695 set = TRUE;
2696
2697 fprintf( stderr, ErrorFormatString" Warning: Property '%s' not writable.\n",
2698 g->fileName.data(), p->lineNo, (const char*) p->name );
2699 fprintf( stderr, " Have been looking for public set functions \n");
2700 if ( !set && p->oredEnum != 1 ) {
2701 fprintf( stderr,
2702 " void %s( %s )\n"
2703 " void %s( %s& )\n"
2704 " void %s( const %s& )\n",
2705 (const char*) p->set, (const char*) p->type,
2706 (const char*) p->set, (const char*) p->type,
2707 (const char*) p->set, (const char*) p->type );
2708 }
2709 if ( set || ( !isPropertyType( p->type ) && p->oredEnum != 0 ) ) {
2710 fprintf( stderr,
2711 " void %s( int )\n"
2712 " void %s( uint )\n"
2713 " void %s( unsigned int )\n",
2714 (const char*) p->set,
2715 (const char*) p->set,
2716 (const char*) p->set );
2717 }
2718
2719 if ( p->type == "QCString" )
2720 fprintf( stderr, " void %s( const char* ) const\n",
2721 (const char*) p->set );
2722
2723 if ( !candidates.isEmpty() ) {
2724 fprintf( stderr, " but only found the mismatching candidate(s)\n");
2725 for ( Function* f = candidates.first(); f; f = candidates.next() ) {
2726 QCString typstr = "";
2727 Argument *a = f->args->first();
2728 int count = 0;
2729 while ( a ) {
2730 if ( !a->leftType.isEmpty() || ! a->rightType.isEmpty() ) {
2731 if ( count++ )
2732 typstr += ",";
2733 typstr += a->leftType;
2734 typstr += a->rightType;
2735 }
2736 a = f->args->next();
2737 }
2738 fprintf( stderr, " %s:%d: %s %s(%s)\n", g->fileName.data(), f->lineNo,
2739 (const char*) f->type,(const char*) f->name, (const char*) typstr );
2740 }
2741 }
2742 }
2743 }
2744 }
2745 }
2746
2747 //
2748 // Create meta data
2749 //
2750 if ( g->props.count() ) {
2751 if ( displayWarnings && !Q_OBJECTdetected )
2752 moc_err("The declaration of the class \"%s\" contains properties"
2753 " but no Q_OBJECT macro.", g->className.data());
2754
2755 fprintf( out, "#ifndef QT_NO_PROPERTIES\n" );
2756
2757 fprintf( out, " static const QMetaProperty props_tbl[%d] = {\n ", g->props.count() );
2758 for( QPtrListIterator<Property> it( g->props ); it.current(); ++it ) {
2759
2760 fprintf( out, "\t{ \"%s\",\"%s\", ", it.current()->type.data(), it.current()->name.data() );
2761 int flags = Invalid;
2762 if ( !isVariantType( it.current()->type ) ) {
2763 flags |= EnumOrSet;
2764 if ( !isEnumType( it.current()->type ) )
2765 flags |= UnresolvedEnum;
2766 } else {
2767 flags |= qvariant_nameToType( it.current()->type ) << 24;
2768 }
2769 if ( it.current()->getfunc )
2770 flags |= Readable;
2771 if ( it.current()->setfunc ) {
2772 flags |= Writable;
2773 if ( it.current()->stdSet() )
2774 flags |= StdSet;
2775 }
2776 if ( it.current()->override )
2777 flags |= Override;
2778
2779 if ( it.current()->designable.isEmpty() )
2780 flags |= DesignableOverride;
2781 else if ( it.current()->designable == "false" )
2782 flags |= NotDesignable;
2783
2784 if ( it.current()->scriptable.isEmpty() )
2785 flags |= ScriptableOverride;
2786 else if ( it.current()->scriptable == "false" )
2787 flags |= NotScriptable;
2788
2789 if ( it.current()->stored.isEmpty() )
2790 flags |= StoredOverride;
2791 else if ( it.current()->stored == "false" )
2792 flags |= NotStored;
2793
2794
2795 fprintf( out, "0x%.4x, ", flags );
2796 fprintf( out, "&%s::metaObj, ", (const char*) qualifiedClassName() );
2797 if ( !isVariantType( it.current()->type ) ) {
2798 int enumpos = -1;
2799 int k = 0;
2800 for( QPtrListIterator<Enum> eit( g->enums ); eit.current(); ++eit, ++k ) {
2801 if ( eit.current()->name == it.current()->type )
2802 enumpos = k;
2803 }
2804
2805 // Is it an enum of this class ?
2806 if ( enumpos != -1 )
2807 fprintf( out, "&enum_tbl[%i], ", enumpos );
2808 else
2809 fprintf( out, "0, ");
2810 } else {
2811 fprintf( out, "0, ");
2812 }
2813 fprintf( out, "-1 }" );
2814 if ( !it.atLast() )
2815 fprintf( out, ",\n" );
2816 else
2817 fprintf( out, "\n" );
2818 }
2819 fprintf( out, " };\n" );
2820 fprintf( out, "#endif // QT_NO_PROPERTIES\n" );
2821 }
2822
2823 return g->props.count();
2824}
2825
2826
2827
2828int generateClassInfos()
2829{
2830 if ( g->infos.isEmpty() )
2831 return 0;
2832
2833 if ( displayWarnings && !Q_OBJECTdetected )
2834 moc_err("The declaration of the class \"%s\" contains class infos"
2835 " but no Q_OBJECT macro.", g->className.data());
2836
2837 fprintf( out, " static const QClassInfo classinfo_tbl[] = {\n" );
2838 int i = 0;
2839 for( QPtrListIterator<ClassInfo> it( g->infos ); it.current(); ++it, ++i ) {
2840 if ( i )
2841 fprintf( out, ",\n" );
2842 fprintf( out, "\t{ \"%s\", \"%s\" }", it.current()->name.data(),it.current()->value.data() );
2843 }
2844 fprintf( out, "\n };\n" );
2845 return i;
2846}
2847
2848
2849void generateClass() // generate C++ source code for a class
2850{
2851 const char *hdr1 = "/****************************************************************************\n"
2852 "** %s meta object code from reading C++ file '%s'\n**\n";
2853 const char *hdr2 = "** Created: %s\n"
2854 "** by: The Qt MOC ($Id: moc_yacc.cpp 2 2005-11-16 15:49:26Z dmik $)\n**\n";
2855 const char *hdr3 = "** WARNING! All changes made in this file will be lost!\n";
2856 const char *hdr4 = "*****************************************************************************/\n\n";
2857 int i;
2858
2859 if ( skipClass ) // don't generate for class
2860 return;
2861
2862 if ( !Q_OBJECTdetected ) {
2863 if ( g->signals.count() == 0 && g->slots.count() == 0 && g->props.count() == 0 && g->infos.count() == 0 )
2864 return;
2865 if ( displayWarnings && (g->signals.count() + g->slots.count()) != 0 )
2866 moc_err("The declaration of the class \"%s\" contains signals "
2867 "or slots\n\t but no Q_OBJECT macro.", g->className.data());
2868 } else {
2869 if ( g->superClassName.isEmpty() )
2870 moc_err("The declaration of the class \"%s\" contains the\n"
2871 "\tQ_OBJECT macro but does not inherit from any class!\n"
2872 "\tInherit from QObject or one of its descendants"
2873 " or remove Q_OBJECT.", g->className.data() );
2874 }
2875 if ( templateClass ) { // don't generate for class
2876 moc_err( "Sorry, Qt does not support templates that contain\n"
2877 "\tsignals, slots or Q_OBJECT." );
2878 return;
2879 }
2880 g->generatedCode = TRUE;
2881 g->gen_count++;
2882
2883 if ( g->gen_count == 1 ) { // first class to be generated
2884 QDateTime dt = QDateTime::currentDateTime();
2885 QCString dstr = dt.toString().ascii();
2886 QCString fn = g->fileName;
2887 i = g->fileName.length()-1;
2888 while ( i>0 && g->fileName[i-1] != '/' && g->fileName[i-1] != '\\' )
2889 i--; // skip path
2890 if ( i >= 0 )
2891 fn = &g->fileName[i];
2892 fprintf( out, hdr1, (const char*)qualifiedClassName(),(const char*)fn);
2893 fprintf( out, hdr2, (const char*)dstr );
2894 fprintf( out, hdr3 );
2895 fprintf( out, hdr4 );
2896
2897 if ( !g->noInclude ) {
2898 /*
2899 The header file might be a Qt header file with
2900 QT_NO_COMPAT macros around signals, slots or
2901 properties. Without the #undef, we cannot compile the
2902 Qt library with QT_NO_COMPAT defined.
2903
2904 Header files of libraries build around Qt can also use
2905 QT_NO_COMPAT, so this #undef might be beneficial to
2906 users of Qt, and not only to developers of Qt.
2907 */
2908 fprintf( out, "#undef QT_NO_COMPAT\n" );
2909
2910 if ( !g->pchFile.isEmpty() )
2911 fprintf( out, "#include \"%s\" // PCH include\n", (const char*)g->pchFile );
2912 if ( !g->includePath.isEmpty() && g->includePath.right(1) != "/" )
2913 g->includePath += "/";
2914
2915 g->includeFiles.first();
2916 while ( g->includeFiles.current() ) {
2917 QCString inc = g->includeFiles.current();
2918 if ( inc[0] != '<' && inc[0] != '"' ) {
2919 if ( !g->includePath.isEmpty() && g->includePath != "./" )
2920 inc.prepend( g->includePath );
2921 inc = "\"" + inc + "\"";
2922 }
2923 fprintf( out, "#include %s\n", (const char *)inc );
2924 g->includeFiles.next();
2925 }
2926 }
2927 fprintf( out, "#include <%sqmetaobject.h>\n", (const char*)g->qtPath );
2928 fprintf( out, "#include <%sqapplication.h>\n\n", (const char*)g->qtPath );
2929 fprintf( out, "#include <%sprivate/qucomextra_p.h>\n", (const char*)g->qtPath );
2930 fprintf( out, "#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != %d)\n", formatRevision );
2931 fprintf( out, "#error \"This file was generated using the moc from %s."
2932 " It\"\n#error \"cannot be used with the include files from"
2933 " this version of Qt.\"\n#error \"(The moc has changed too"
2934 " much.)\"\n", QT_VERSION_STR );
2935 fprintf( out, "#endif\n\n" );
2936 } else {
2937 fprintf( out, "\n\n" );
2938 }
2939
2940 if ( !g->hasVariantIncluded ) {
2941 bool needToIncludeVariant = !g->props.isEmpty();
2942 for ( Function* f =g->slots.first(); f && !needToIncludeVariant; f=g->slots.next() )
2943 needToIncludeVariant = ( f->type != "void" && !validUType( f->type ) && isVariantType( f->type) );
2944
2945 if ( needToIncludeVariant ) {
2946 fprintf( out, "#include <%sqvariant.h>\n", (const char*)g->qtPath );
2947 g->hasVariantIncluded = TRUE;
2948 }
2949 }
2950
2951 bool isQObject = g->className == "QObject" ;
2952
2953
2954//
2955// Generate virtual function className()
2956//
2957 fprintf( out, "const char *%s::className() const\n{\n ",
2958 (const char*)qualifiedClassName() );
2959 fprintf( out, "return \"%s\";\n}\n\n", (const char*)qualifiedClassName() );
2960
2961//
2962// Generate static metaObj variable
2963//
2964 fprintf( out, "QMetaObject *%s::metaObj = 0;\n", (const char*)qualifiedClassName());
2965
2966//
2967// Generate static cleanup object variable
2968//
2969 QCString cleanup = qualifiedClassName().copy();
2970 for ( int cnpos = 0; cnpos < cleanup.length(); cnpos++ ) {
2971 if ( cleanup[cnpos] == ':' )
2972 cleanup[cnpos] = '_';
2973 }
2974
2975 fprintf( out, "static QMetaObjectCleanUp cleanUp_%s( \"%s\", &%s::staticMetaObject );\n\n", (const char*)cleanup, (const char*)qualifiedClassName(), (const char*)qualifiedClassName() );
2976
2977//
2978// Generate tr and trUtf8 member functions
2979//
2980 fprintf( out, "#ifndef QT_NO_TRANSLATION\n" );
2981 fprintf( out, "QString %s::tr( const char *s, const char *c )\n{\n",
2982 (const char*)qualifiedClassName() );
2983 fprintf( out, " if ( qApp )\n" );
2984 fprintf( out, "\treturn qApp->translate( \"%s\", s, c,"
2985 " QApplication::DefaultCodec );\n",
2986 (const char*)qualifiedClassName() );
2987 fprintf( out, " else\n" );
2988 fprintf( out, "\treturn QString::fromLatin1( s );\n");
2989 fprintf( out, "}\n" );
2990 fprintf( out, "#ifndef QT_NO_TRANSLATION_UTF8\n" );
2991 fprintf( out, "QString %s::trUtf8( const char *s, const char *c )\n{\n",
2992 (const char*)qualifiedClassName() );
2993 fprintf( out, " if ( qApp )\n" );
2994 fprintf( out, "\treturn qApp->translate( \"%s\", s, c,"
2995 " QApplication::UnicodeUTF8 );\n",
2996 (const char*)qualifiedClassName() );
2997 fprintf( out, " else\n" );
2998 fprintf( out, "\treturn QString::fromUtf8( s );\n" );
2999 fprintf( out, "}\n" );
3000 fprintf( out, "#endif // QT_NO_TRANSLATION_UTF8\n\n" );
3001 fprintf( out, "#endif // QT_NO_TRANSLATION\n\n" );
3002
3003//
3004// Generate staticMetaObject member function
3005//
3006 fprintf( out, "QMetaObject* %s::staticMetaObject()\n{\n", (const char*)qualifiedClassName() );
3007 fprintf( out, " if ( metaObj )\n\treturn metaObj;\n" );
3008 if ( isQObject )
3009 fprintf( out, " QMetaObject* parentObject = staticQtMetaObject();\n" );
3010 else if ( !g->superClassName.isEmpty() )
3011 fprintf( out, " QMetaObject* parentObject = %s::staticMetaObject();\n", (const char*)g->superClassName );
3012 else
3013 fprintf( out, " QMetaObject* parentObject = 0;\n" );
3014
3015//
3016// Build the classinfo array
3017//
3018 int n_infos = generateClassInfos();
3019
3020// Build the enums array
3021// Enums HAVE to be generated BEFORE the properties and slots
3022//
3023 int n_enums = generateEnums();
3024
3025//
3026// Build slots array in staticMetaObject()
3027//
3028 generateFuncs( &g->slots, "slot", Slot_Num );
3029
3030//
3031// Build signals array in staticMetaObject()
3032//
3033 generateFuncs( &g->signals, "signal", Signal_Num );
3034
3035//
3036// Build property array in staticMetaObject()
3037//
3038 int n_props = generateProps();
3039
3040//
3041// Finally code to create and return meta object
3042//
3043 fprintf( out, " metaObj = QMetaObject::new_metaobject(\n"
3044 "\t\"%s\", parentObject,\n", (const char*)qualifiedClassName() );
3045
3046 if ( g->slots.count() )
3047 fprintf( out, "\tslot_tbl, %d,\n", g->slots.count() );
3048 else
3049 fprintf( out, "\t0, 0,\n" );
3050
3051 if ( g->signals.count() )
3052 fprintf( out, "\tsignal_tbl, %d,\n", g->signals.count() );
3053 else
3054 fprintf( out, "\t0, 0,\n" );
3055
3056 fprintf( out, "#ifndef QT_NO_PROPERTIES\n" );
3057 if ( n_props )
3058 fprintf( out, "\tprops_tbl, %d,\n", n_props );
3059 else
3060 fprintf( out, "\t0, 0,\n" );
3061 if ( n_enums )
3062 fprintf( out, "\tenum_tbl, %d,\n", n_enums );
3063 else
3064 fprintf( out, "\t0, 0,\n" );
3065 fprintf( out, "#endif // QT_NO_PROPERTIES\n" );
3066
3067 if ( n_infos )
3068 fprintf( out, "\tclassinfo_tbl, %d );\n", n_infos );
3069 else
3070 fprintf( out, "\t0, 0 );\n" );
3071
3072
3073//
3074// Setup cleanup handler and return meta object
3075//
3076 fprintf( out, " cleanUp_%s.setMetaObject( metaObj );\n", cleanup.data() );
3077 fprintf( out, " return metaObj;\n}\n" );
3078
3079//
3080// End of function staticMetaObject()
3081//
3082
3083//
3084// Generate smart cast function
3085//
3086 fprintf( out, "\nvoid* %s::qt_cast( const char* clname )\n{\n",
3087 (const char*)qualifiedClassName() );
3088 fprintf( out, " if ( !qstrcmp( clname, \"%s\" ) )\n"
3089 "\treturn this;\n",
3090 (const char*)qualifiedClassName() );
3091 for ( const char* cname = g->multipleSuperClasses.first(); cname; cname = g->multipleSuperClasses.next() )
3092 fprintf( out, " if ( !qstrcmp( clname, \"%s\" ) )\n"
3093 "\treturn (%s*)this;\n", cname, cname );
3094 if ( !g->superClassName.isEmpty() && !isQObject )
3095 fprintf( out, " return %s::qt_cast( clname );\n",
3096 (const char*)purestSuperClassName() );
3097 else
3098 fprintf( out, " return 0;\n" );
3099 fprintf( out, "}\n" );
3100
3101//
3102// Generate internal signal functions
3103//
3104 Function *f;
3105 f = g->signals.first(); // make internal signal methods
3106 static bool included_list_headers = FALSE;
3107 int sigindex = 0;
3108 while ( f ) {
3109 QCString argstr;
3110 char buf[12];
3111 Argument *a = f->args->first();
3112 int offset = 0;
3113 const char *predef_call_func = 0;
3114 bool hasReturnValue = f->type != "void" && (validUType( f->type ) || isVariantType( f->type) );
3115 if ( hasReturnValue ) {
3116 ; // no predefined function available
3117 } else if ( !a ) {
3118 predef_call_func = "activate_signal";
3119 } else if ( f->args->count() == 1 ) {
3120 QCString ctype = (a->leftType + ' ' + a->rightType).simplifyWhiteSpace();
3121 if ( !isInOut( ctype ) ) {
3122 QCString utype = uType( ctype );
3123 if ( utype == "bool" )
3124 predef_call_func = "activate_signal_bool";
3125 else if ( utype == "QString" || utype == "int" || utype == "double" )
3126 predef_call_func = "activate_signal";
3127 }
3128 }
3129
3130 if ( !predef_call_func && !included_list_headers ) {
3131 // yes we need it, because otherwise QT_VERSION may not be defined
3132 fprintf( out, "\n#include <%sqobjectdefs.h>\n", (const char*)g->qtPath );
3133 fprintf( out, "#include <%sqsignalslotimp.h>\n", (const char*)g->qtPath );
3134 included_list_headers = TRUE;
3135 }
3136
3137 while ( a ) { // argument list
3138 if ( !a->leftType.isEmpty() || !a->rightType.isEmpty() ) {
3139 argstr += a->leftType;
3140 argstr += " ";
3141 sprintf( buf, "t%d", offset++ );
3142 argstr += buf;
3143 argstr += a->rightType;
3144 a = f->args->next();
3145 if ( a )
3146 argstr += ", ";
3147 } else {
3148 a = f->args->next();
3149 }
3150 }
3151
3152 fixRightAngles( &argstr );
3153
3154 fprintf( out, "\n// SIGNAL %s\n", (const char*)f->name );
3155 fprintf( out, "%s %s::%s(", (const char*) f->type,
3156 (const char*)qualifiedClassName(),
3157 (const char*)f->name );
3158
3159 if ( argstr.isEmpty() )
3160 fprintf( out, ")\n{\n" );
3161 else
3162 fprintf( out, " %s )\n{\n", (const char*)argstr );
3163
3164 if ( predef_call_func ) {
3165 fprintf( out, " %s( staticMetaObject()->signalOffset() + %d", predef_call_func, sigindex );
3166 if ( !argstr.isEmpty() )
3167 fprintf( out, ", t0" );
3168 fprintf( out, " );\n}\n" );
3169 } else {
3170 if ( hasReturnValue )
3171 fprintf( out, " %s something;\n", f->type.data() );
3172 int nargs = f->args->count();
3173 fprintf( out, " if ( signalsBlocked() )\n\treturn%s;\n", hasReturnValue ? " something" : "" );
3174 fprintf( out, " QConnectionList *clist = receivers( staticMetaObject()->signalOffset() + %d );\n",
3175 sigindex );
3176 fprintf( out, " if ( !clist )\n\treturn%s;\n", hasReturnValue ? " something" : "" );
3177 fprintf( out, " QUObject o[%d];\n", f->args->count() + 1 );
3178
3179 // initialize return value to something
3180 if ( hasReturnValue ) {
3181 if ( validUType( f->type ) ) {
3182 QCString utype = uType( f->type );
3183 fprintf( out, " static_QUType_%s.set(o,something);\n", utype.data() );
3184 } else if ( uType( f->type ) == "varptr" ) {
3185 fprintf( out, " static_QUType_varptr.set(o,&something);\n" );
3186 } else {
3187 fprintf( out, " static_QUType_ptr.set(o,&something);\n" );
3188 }
3189 }
3190
3191 // initialize arguments
3192 if ( !f->args->isEmpty() ) {
3193 offset = 0;
3194 Argument* a = f->args->first();
3195 while ( a ) {
3196 QCString type = a->leftType + ' ' + a->rightType;
3197 type = type.simplifyWhiteSpace();
3198 if ( validUType( type ) ) {
3199 QCString utype = uType( type );
3200 fprintf( out, " static_QUType_%s.set(o+%d,t%d);\n", utype.data(), offset+1, offset );
3201 } else if ( uType( type ) == "varptr" ) {
3202 fprintf( out, " static_QUType_varptr.set(o+%d,&t%d);\n", offset+1, offset );
3203 } else {
3204 fprintf( out, " static_QUType_ptr.set(o+%d,&t%d);\n", offset+1, offset );
3205 }
3206 a = f->args->next();
3207 offset++;
3208 }
3209 }
3210 fprintf( out, " activate_signal( clist, o );\n" );
3211
3212 // get return values from inOut parameters
3213 if ( !f->args->isEmpty() ) {
3214 offset = 0;
3215 Argument* a = f->args->first();
3216 while ( a ) {
3217 QCString type = a->leftType + ' ' + a->rightType;
3218 type = type.simplifyWhiteSpace();
3219 if ( validUType( type ) && isInOut( type ) ) {
3220 QCString utype = uType( type );
3221 if ( utype == "enum" )
3222 fprintf( out, " t%d = (%s)static_QUType_%s.get(o+%d);\n", offset, type.data(), utype.data(), offset+1 );
3223 else if ( utype == "ptr" && type.right(2) == "**" )
3224 fprintf( out, " if (t%d) *t%d = *(%s)static_QUType_ptr.get(o+%d);\n", offset, offset, type.data(), offset+1 );
3225 else
3226 fprintf( out, " t%d = static_QUType_%s.get(o+%d);\n", offset, utype.data(), offset+1 );
3227 }
3228 a = f->args->next();
3229 offset++;
3230 }
3231 }
3232
3233 // get and return return value
3234 if ( hasReturnValue ) {
3235 QCString utype = uType( f->type );
3236 if ( utype == "enum" || utype == "ptr" || utype == "varptr" ) // need cast
3237 fprintf( out, " return (%s)static_QUType_%s.get(o);\n", f->type.data(), utype.data() );
3238 else
3239 fprintf( out, " return static_QUType_%s.get(o);\n", utype.data() );
3240 }
3241
3242 fprintf( out, "}\n" );
3243 }
3244
3245 f = g->signals.next();
3246 sigindex++;
3247 }
3248
3249
3250//
3251// Generate internal qt_invoke() function
3252//
3253 fprintf( out, "\nbool %s::qt_invoke( int _id, QUObject* _o )\n{\n", qualifiedClassName().data() );
3254
3255 if( !g->slots.isEmpty() ) {
3256 fprintf( out, " switch ( _id - staticMetaObject()->slotOffset() ) {\n" );
3257 int slotindex = -1;
3258 for ( f = g->slots.first(); f; f = g->slots.next() ) {
3259 slotindex ++;
3260 if ( f->type == "void" && f->args->isEmpty() ) {
3261 fprintf( out, " case %d: %s(); break;\n", slotindex, f->name.data() );
3262 continue;
3263 }
3264
3265 fprintf( out, " case %d: ", slotindex );
3266 bool hasReturnValue = FALSE;
3267 bool hasVariantReturn = FALSE;
3268 if ( f->type != "void" ) {
3269 if ( validUType( f->type )) {
3270 hasReturnValue = TRUE;
3271 fprintf( out, "static_QUType_%s.set(_o,", uType(f->type).data() );
3272 } else if ( isVariantType( f->type ) ) {
3273 hasReturnValue = hasVariantReturn = TRUE;
3274 // do not need special handling for bool since this is handled as utype
3275 fprintf( out, "static_QUType_QVariant.set(_o,QVariant(" );
3276 }
3277 }
3278 int offset = 0;
3279 fprintf( out, "%s(", f->name.data() );
3280 Argument* a = f->args->first();
3281 while ( a ) {
3282 QCString type = a->leftType + ' ' + a->rightType;
3283 type = type.simplifyWhiteSpace();
3284 fixRightAngles( &type );
3285 if ( validUType( type ) ) {
3286 QCString utype = uType( type );
3287 if ( utype == "ptr" || utype == "varptr" || utype == "enum" )
3288 fprintf( out, "(%s)static_QUType_%s.get(_o+%d)", type.data(), utype.data(), offset+1 );
3289 else
3290 fprintf( out, "(%s)static_QUType_%s.get(_o+%d)", type.data(), utype.data(), offset+1 );
3291 } else {
3292 QCString castType = castToUType( type );
3293 if(castType == type)
3294 fprintf( out, "(%s)(*((%s*)static_QUType_ptr.get(_o+%d)))", type.data(),
3295 castType.data(), offset+1 );
3296 else
3297 fprintf( out, "(%s)*((%s*)static_QUType_ptr.get(_o+%d))", type.data(),
3298 castType.data(), offset+1 );
3299 }
3300 a = f->args->next();
3301 if ( a )
3302 fprintf( out, "," );
3303 offset++;
3304 }
3305 fprintf( out, ")" );
3306 if ( hasReturnValue )
3307 fprintf( out, ")" );
3308 if ( hasVariantReturn )
3309 fprintf( out, ")" );
3310 fprintf( out, "; break;\n" );
3311 }
3312 fprintf( out, " default:\n" );
3313
3314 if ( !g->superClassName.isEmpty() && !isQObject ) {
3315 fprintf( out, "\treturn %s::qt_invoke( _id, _o );\n",
3316 (const char *) purestSuperClassName() );
3317 } else {
3318 fprintf( out, "\treturn FALSE;\n" );
3319 }
3320 fprintf( out, " }\n" );
3321 fprintf( out, " return TRUE;\n}\n" );
3322 } else {
3323 if ( !g->superClassName.isEmpty() && !isQObject )
3324 fprintf( out, " return %s::qt_invoke(_id,_o);\n}\n",
3325 (const char *) purestSuperClassName() );
3326 else
3327 fprintf( out, " return FALSE;\n}\n" );
3328 }
3329
3330
3331//
3332// Generate internal qt_emit() function
3333//
3334 fprintf( out, "\nbool %s::qt_emit( int _id, QUObject* _o )\n{\n", qualifiedClassName().data() );
3335
3336 if ( !g->signals.isEmpty() ) {
3337 fprintf( out, " switch ( _id - staticMetaObject()->signalOffset() ) {\n" );
3338 int signalindex = -1;
3339 for ( f = g->signals.first(); f; f = g->signals.next() ) {
3340 signalindex++;
3341 if ( f->type == "void" && f->args->isEmpty() ) {
3342 fprintf( out, " case %d: %s(); break;\n", signalindex, f->name.data() );
3343 continue;
3344 }
3345
3346 fprintf( out, " case %d: ", signalindex );
3347 bool hasReturnValue = FALSE;
3348 if ( f->type != "void" && validUType( f->type )) {
3349 hasReturnValue = TRUE;
3350 fprintf( out, "static_QUType_%s.set(_o,", uType(f->type).data() );
3351 }
3352 int offset = 0;
3353 fprintf( out, "%s(", f->name.data() );
3354 Argument* a = f->args->first();
3355 while ( a ) {
3356 QCString type = a->leftType + ' ' + a->rightType;
3357 type = type.simplifyWhiteSpace();
3358 fixRightAngles( &type );
3359 if ( validUType( type ) ) {
3360 QCString utype = uType( type );
3361 if ( utype == "ptr" || utype == "varptr" || utype == "enum" )
3362 fprintf( out, "(%s)static_QUType_%s.get(_o+%d)", type.data(), utype.data(), offset+1 );
3363 else
3364 fprintf( out, "(%s)static_QUType_%s.get(_o+%d)", type.data(), utype.data(), offset+1 );
3365 } else {
3366 QCString castType = castToUType( type );
3367 if(castType == type)
3368 fprintf( out, "(%s)(*((%s*)static_QUType_ptr.get(_o+%d)))", type.data(),
3369 castType.data(), offset+1 );
3370 else
3371 fprintf( out, "(%s)*((%s*)static_QUType_ptr.get(_o+%d))", type.data(),
3372 castType.data(), offset+1 );
3373 }
3374 a = f->args->next();
3375 if ( a )
3376 fprintf( out, "," );
3377 offset++;
3378 }
3379 fprintf( out, ")" );
3380 if ( hasReturnValue )
3381 fprintf( out, ")" );
3382 fprintf( out, "; break;\n" );
3383 }
3384 fprintf( out, " default:\n" );
3385 if ( !g->superClassName.isEmpty() && !isQObject )
3386 fprintf( out, "\treturn %s::qt_emit(_id,_o);\n",
3387 (const char *) purestSuperClassName() );
3388 else
3389 fprintf( out, "\treturn FALSE;\n" );
3390 fprintf( out, " }\n" );
3391 fprintf( out, " return TRUE;\n}\n" );
3392 } else {
3393 if ( !g->superClassName.isEmpty() && !isQObject )
3394 fprintf( out, " return %s::qt_emit(_id,_o);\n}\n",
3395 (const char *) purestSuperClassName() );
3396 else
3397 fprintf( out, " return FALSE;\n}\n" );
3398 }
3399
3400
3401 fprintf( out, "#ifndef QT_NO_PROPERTIES\n" );
3402//
3403// Generate internal qt_property() functions
3404//
3405
3406 fprintf( out, "\nbool %s::qt_property( int id, int f, QVariant* v)\n{\n", qualifiedClassName().data() );
3407
3408 if ( !g->props.isEmpty() ) {
3409 fprintf( out, " switch ( id - staticMetaObject()->propertyOffset() ) {\n" );
3410 int propindex = -1;
3411 bool need_resolve = FALSE;
3412
3413 for( QPtrListIterator<Property> it( g->props ); it.current(); ++it ){
3414 propindex ++;
3415 fprintf( out, " case %d: ", propindex );
3416 fprintf( out, "switch( f ) {\n" );
3417
3418 uint flag_break = 0;
3419 uint flag_propagate = 0;
3420
3421 if ( it.current()->setfunc ) {
3422 fprintf( out, "\tcase 0: %s(", it.current()->setfunc->name.data() );
3423 QCString type = it.current()->type.copy(); // detach on purpose
3424 if ( it.current()->oredEnum )
3425 type = it.current()->enumsettype;
3426 if ( type == "uint" )
3427 fprintf( out, "v->asUInt()" );
3428 else if ( type == "unsigned int" )
3429 fprintf( out, "(uint)v->asUInt()" );
3430 else if ( type == "QMap<QString,QVariant>" )
3431 fprintf( out, "v->asMap()" );
3432 else if ( type == "QValueList<QVariant>" )
3433 fprintf( out, "v->asList()" );
3434 else if ( type == "Q_LLONG" )
3435 fprintf( out, "v->asLongLong()" );
3436 else if ( type == "Q_ULLONG" )
3437 fprintf( out, "v->asULongLong()" );
3438 else if ( isVariantType( type ) ) {
3439 if ( type[0] == 'Q' )
3440 type = type.mid(1);
3441 else
3442 type[0] = toupper( type[0] );
3443 fprintf( out, "v->as%s()", type.data() );
3444 } else {
3445 fprintf( out, "(%s&)v->asInt()", type.data() );
3446 }
3447 fprintf( out, "); break;\n" );
3448
3449 } else if ( it.current()->override ) {
3450 flag_propagate |= 1 << (0+1);
3451 }
3452 if ( it.current()->getfunc ) {
3453 if ( it.current()->gspec == Property::Pointer )
3454 fprintf( out, "\tcase 1: if ( this->%s() ) *v = QVariant( %s*%s()%s ); break;\n",
3455 it.current()->getfunc->name.data(),
3456 !isVariantType( it.current()->type ) ? "(int)" : "",
3457 it.current()->getfunc->name.data(),
3458 it.current()->type == "bool" ? ", 0" : "" );
3459 else
3460 fprintf( out, "\tcase 1: *v = QVariant( %sthis->%s()%s ); break;\n",
3461 !isVariantType( it.current()->type ) ? "(int)" : "",
3462 it.current()->getfunc->name.data(),
3463 it.current()->type == "bool" ? ", 0" : "" );
3464 } else if ( it.current()->override ) {
3465 flag_propagate |= 1<< (1+1);
3466 }
3467
3468 if ( !it.current()->reset.isEmpty() )
3469 fprintf( out, "\tcase 2: this->%s(); break;\n", it.current()->reset.data() );
3470
3471 if ( it.current()->designable.isEmpty() )
3472 flag_propagate |= 1 << (3+1);
3473 else if ( it.current()->designable == "true" )
3474 flag_break |= 1 << (3+1);
3475 else if ( it.current()->designable != "false" )
3476 fprintf( out, "\tcase 3: return this->%s();\n", it.current()->designable.data() );
3477
3478 if ( it.current()->scriptable.isEmpty() )
3479 flag_propagate |= 1 << (4+1);
3480 else if ( it.current()->scriptable == "true" )
3481 flag_break |= 1 << (4+1);
3482 else if ( it.current()->scriptable != "false" )
3483 fprintf( out, "\tcase 4: return this->%s();\n", it.current()->scriptable.data() );
3484
3485 if ( it.current()->stored.isEmpty() )
3486 flag_propagate |= 1 << (5+1);
3487 else if ( it.current()->stored == "true" )
3488 flag_break |= 1 << (5+1);
3489 else if ( it.current()->stored != "false" )
3490 fprintf( out, "\tcase 5: return this->%s();\n", it.current()->stored.data() );
3491
3492 int i = 0;
3493 if ( flag_propagate != 0 ) {
3494 fprintf( out, "\t" );
3495 for ( i = 0; i <= 5; i++ ) {
3496 if ( flag_propagate & (1 << (i+1) ) )
3497 fprintf( out, "case %d: ", i );
3498 }
3499 if (!g->superClassName.isEmpty() && !isQObject ) {
3500 fprintf( out, "goto resolve;\n" );
3501 need_resolve = TRUE;
3502 } else {
3503 fprintf( out, " return FALSE;\n" );
3504 }
3505 }
3506 if ( flag_break != 0 ) {
3507 fprintf( out, "\t" );
3508 for ( i = 0; i <= 5; i++ ) {
3509 if ( flag_break & (1 << (i+1) ) )
3510 fprintf( out, "case %d: ", i );
3511 }
3512 fprintf( out, "break;\n");
3513 }
3514
3515 fprintf( out, "\tdefault: return FALSE;\n } break;\n" );
3516 }
3517 fprintf( out, " default:\n" );
3518 if ( !g->superClassName.isEmpty() && !isQObject )
3519 fprintf( out, "\treturn %s::qt_property( id, f, v );\n",
3520 (const char *) purestSuperClassName() );
3521 else
3522 fprintf( out, "\treturn FALSE;\n" );
3523 fprintf( out, " }\n" );
3524 fprintf( out, " return TRUE;\n" );
3525
3526 if ( need_resolve )
3527 fprintf( out, "resolve:\n return %s::qt_property( staticMetaObject()->resolveProperty(id), f, v );\n",
3528 (const char *) purestSuperClassName() );
3529 fprintf( out, "}\n" );
3530 } else {
3531 if ( !g->superClassName.isEmpty() && !isQObject )
3532 fprintf( out, " return %s::qt_property( id, f, v);\n}\n",
3533 (const char *) purestSuperClassName() );
3534 else
3535 fprintf( out, " return FALSE;\n}\n" );
3536 }
3537
3538 fprintf( out, "\nbool %s::qt_static_property( QObject* , int , int , QVariant* ){ return FALSE; }\n", qualifiedClassName().data() );
3539 fprintf( out, "#endif // QT_NO_PROPERTIES\n" );
3540}
3541
3542
3543ArgList *addArg( Argument *a ) // add argument to list
3544{
3545 if ( (!a->leftType.isEmpty() || !a->rightType.isEmpty() ) ) //filter out truely void arguments
3546 tmpArgList->append( a );
3547 return tmpArgList;
3548}
3549
3550void addEnum()
3551{
3552 // Avoid duplicates
3553 for( QPtrListIterator<Enum> lit( g->enums ); lit.current(); ++lit ) {
3554 if ( lit.current()->name == tmpEnum->name )
3555 {
3556 if ( displayWarnings )
3557 moc_err( "Enum %s defined twice.", (const char*)tmpEnum->name );
3558 }
3559 }
3560
3561 // Only look at types mentioned in Q_ENUMS and Q_SETS
3562 if ( g->qtEnums.contains( tmpEnum->name ) || g->qtSets.contains( tmpEnum->name ) )
3563 {
3564 g->enums.append( tmpEnum );
3565 if ( g->qtSets.contains( tmpEnum->name ) )
3566 tmpEnum->set = TRUE;
3567 else
3568 tmpEnum->set = FALSE;
3569 }
3570 else
3571 delete tmpEnum;
3572 tmpEnum = new Enum;
3573}
3574
3575void addMember( Member m )
3576{
3577 if ( skipFunc ) {
3578 tmpFunc->args = tmpArgList; // just to be sure
3579 delete tmpFunc;
3580 tmpArgList = new ArgList; // ugly but works
3581 tmpFunc = new Function;
3582 skipFunc = FALSE;
3583 return;
3584 }
3585
3586 tmpFunc->type = tmpFunc->type.simplifyWhiteSpace();
3587 tmpFunc->access = tmpAccess;
3588 tmpFunc->args = tmpArgList;
3589 tmpFunc->lineNo = lineNo;
3590
3591 for ( ;; ) {
3592 g->funcs.append( tmpFunc );
3593
3594 if ( m == SignalMember ) {
3595 g->signals.append( tmpFunc );
3596 break;
3597 } else {
3598 if ( m == SlotMember )
3599 g->slots.append( tmpFunc );
3600 // PropertyCandidateMember or SlotMember
3601 if ( !tmpFunc->name.isEmpty() && tmpFunc->access == Public )
3602 g->propfuncs.append( tmpFunc );
3603 if ( !tmpFunc->args || !tmpFunc->args->hasDefaultArguments() )
3604 break;
3605 tmpFunc = new Function( *tmpFunc );
3606 tmpFunc->args = tmpFunc->args->magicClone();
3607 }
3608 }
3609
3610 skipFunc = FALSE;
3611 tmpFunc = new Function;
3612 tmpArgList = new ArgList;
3613}
3614
3615void checkPropertyName( const char* ident )
3616{
3617 if ( ident[0] == '_' ) {
3618 moc_err( "Invalid property name '%s'.", ident );
3619 return;
3620 }
3621}
3622#line 3623 "y.tab.c"
3623#define YYABORT goto yyabort
3624#define YYREJECT goto yyabort
3625#define YYACCEPT goto yyaccept
3626#define YYERROR goto yyerrlab
3627int
3628yyparse()
3629{
3630 register int yym, yyn, yystate;
3631#if YYDEBUG
3632 register char *yys;
3633 extern char *getenv();
3634
3635 if (yys = getenv("YYDEBUG"))
3636 {
3637 yyn = *yys;
3638 if (yyn >= '0' && yyn <= '9')
3639 yydebug = yyn - '0';
3640 }
3641#endif
3642
3643 yynerrs = 0;
3644 yyerrflag = 0;
3645 yychar = (-1);
3646
3647 yyssp = yyss;
3648 yyvsp = yyvs;
3649 *yyssp = yystate = 0;
3650
3651yyloop:
3652 if (yyn = yydefred[yystate]) goto yyreduce;
3653 if (yychar < 0)
3654 {
3655 if ((yychar = yylex()) < 0) yychar = 0;
3656#if YYDEBUG
3657 if (yydebug)
3658 {
3659 yys = 0;
3660 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
3661 if (!yys) yys = "illegal-symbol";
3662 printf("%sdebug: state %d, reading %d (%s)\n",
3663 YYPREFIX, yystate, yychar, yys);
3664 }
3665#endif
3666 }
3667 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
3668 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
3669 {
3670#if YYDEBUG
3671 if (yydebug)
3672 printf("%sdebug: state %d, shifting to state %d\n",
3673 YYPREFIX, yystate, yytable[yyn]);
3674#endif
3675 if (yyssp >= yyss + yystacksize - 1)
3676 {
3677 goto yyoverflow;
3678 }
3679 *++yyssp = yystate = yytable[yyn];
3680 *++yyvsp = yylval;
3681 yychar = (-1);
3682 if (yyerrflag > 0) --yyerrflag;
3683 goto yyloop;
3684 }
3685 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
3686 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
3687 {
3688 yyn = yytable[yyn];
3689 goto yyreduce;
3690 }
3691 if (yyerrflag) goto yyinrecovery;
3692#ifdef lint
3693 goto yynewerror;
3694#endif
3695yynewerror:
3696 yyerror("syntax error");
3697#ifdef lint
3698 goto yyerrlab;
3699#endif
3700yyerrlab:
3701 ++yynerrs;
3702yyinrecovery:
3703 if (yyerrflag < 3)
3704 {
3705 yyerrflag = 3;
3706 for (;;)
3707 {
3708 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
3709 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
3710 {
3711#if YYDEBUG
3712 if (yydebug)
3713 printf("%sdebug: state %d, error recovery shifting\
3714 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
3715#endif
3716 if (yyssp >= yyss + yystacksize - 1)
3717 {
3718 goto yyoverflow;
3719 }
3720 *++yyssp = yystate = yytable[yyn];
3721 *++yyvsp = yylval;
3722 goto yyloop;
3723 }
3724 else
3725 {
3726#if YYDEBUG
3727 if (yydebug)
3728 printf("%sdebug: error recovery discarding state %d\n",
3729 YYPREFIX, *yyssp);
3730#endif
3731 if (yyssp <= yyss) goto yyabort;
3732 --yyssp;
3733 --yyvsp;
3734 }
3735 }
3736 }
3737 else
3738 {
3739 if (yychar == 0) goto yyabort;
3740#if YYDEBUG
3741 if (yydebug)
3742 {
3743 yys = 0;
3744 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
3745 if (!yys) yys = "illegal-symbol";
3746 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
3747 YYPREFIX, yystate, yychar, yys);
3748 }
3749#endif
3750 yychar = (-1);
3751 goto yyloop;
3752 }
3753yyreduce:
3754#if YYDEBUG
3755 if (yydebug)
3756 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
3757 YYPREFIX, yystate, yyn, yyrule[yyn]);
3758#endif
3759 yym = yylen[yyn];
3760 yyval = yyvsp[1-yym];
3761 switch (yyn)
3762 {
3763case 10:
3764#line 794 "moc.y"
3765{ enterNameSpace(yyvsp[0].string); }
3766break;
3767case 11:
3768#line 795 "moc.y"
3769{ BEGIN IN_NAMESPACE; }
3770break;
3771case 12:
3772#line 797 "moc.y"
3773{ leaveNameSpace();
3774 selectOutsideClassState();
3775 }
3776break;
3777case 13:
3778#line 802 "moc.y"
3779{ enterNameSpace(); }
3780break;
3781case 14:
3782#line 803 "moc.y"
3783{ BEGIN IN_NAMESPACE; }
3784break;
3785case 15:
3786#line 805 "moc.y"
3787{ leaveNameSpace();
3788 selectOutsideClassState();
3789 }
3790break;
3791case 17:
3792#line 814 "moc.y"
3793{ selectOutsideClassState(); }
3794break;
3795case 18:
3796#line 818 "moc.y"
3797{ selectOutsideClassState(); }
3798break;
3799case 19:
3800#line 821 "moc.y"
3801{ selectOutsideClassState(); }
3802break;
3803case 20:
3804#line 822 "moc.y"
3805{ selectOutsideClassState(); }
3806break;
3807case 21:
3808#line 825 "moc.y"
3809{ initClass(); }
3810break;
3811case 22:
3812#line 826 "moc.y"
3813{ generateClass();
3814 registerClassInNamespace();
3815 selectOutsideClassState(); }
3816break;
3817case 23:
3818#line 834 "moc.y"
3819{ yyval.string = yyvsp[0].string; }
3820break;
3821case 24:
3822#line 835 "moc.y"
3823{ yyval.string = yyvsp[0].string; }
3824break;
3825case 25:
3826#line 839 "moc.y"
3827{ g->tmpExpression = rmWS( g->tmpExpression );
3828 yyval.string = stradd( yyvsp[-3].string, "<",
3829 g->tmpExpression, ">" ); }
3830break;
3831case 26:
3832#line 850 "moc.y"
3833{ initExpression();
3834 templLevel = 1;
3835 BEGIN IN_TEMPL_ARGS; }
3836break;
3837case 27:
3838#line 863 "moc.y"
3839{ initExpression();
3840 BEGIN IN_EXPR; }
3841break;
3842case 28:
3843#line 872 "moc.y"
3844{ BEGIN IN_DEF_ARG; }
3845break;
3846case 29:
3847#line 875 "moc.y"
3848{ initExpression();
3849 BEGIN IN_ENUM; }
3850break;
3851case 30:
3852#line 881 "moc.y"
3853{ yyval.string = ""; }
3854break;
3855case 31:
3856#line 882 "moc.y"
3857{ yyval.string = yyvsp[0].string; }
3858break;
3859case 32:
3860#line 883 "moc.y"
3861{ yyval.string = ""; }
3862break;
3863case 33:
3864#line 884 "moc.y"
3865{ skipFunc = TRUE; yyval.string = ""; }
3866break;
3867case 34:
3868#line 885 "moc.y"
3869{ skipFunc = TRUE; yyval.string = ""; }
3870break;
3871case 35:
3872#line 889 "moc.y"
3873{ yyval.string = straddSpc(yyvsp[-2].string,yyvsp[-1].string,yyvsp[0].string); }
3874break;
3875case 36:
3876#line 891 "moc.y"
3877{ yyval.string = ""; }
3878break;
3879case 37:
3880#line 892 "moc.y"
3881{ yyval.string = yyvsp[0].string; }
3882break;
3883case 38:
3884#line 895 "moc.y"
3885{ yyval.string = yyvsp[0].string; }
3886break;
3887case 39:
3888#line 896 "moc.y"
3889{ yyval.string = straddSpc(yyvsp[-1].string,yyvsp[0].string); }
3890break;
3891case 42:
3892#line 901 "moc.y"
3893{ skipFunc = TRUE; }
3894break;
3895case 44:
3896#line 905 "moc.y"
3897{ }
3898break;
3899case 45:
3900#line 906 "moc.y"
3901{ }
3902break;
3903case 46:
3904#line 909 "moc.y"
3905{ yyval.string = "const"; }
3906break;
3907case 47:
3908#line 910 "moc.y"
3909{ yyval.string = "volatile"; }
3910break;
3911case 48:
3912#line 913 "moc.y"
3913{ yyval.string = yyvsp[0].string; }
3914break;
3915case 49:
3916#line 914 "moc.y"
3917{ yyval.string = yyvsp[0].string; }
3918break;
3919case 50:
3920#line 915 "moc.y"
3921{ yyval.string = yyvsp[0].string; }
3922break;
3923case 51:
3924#line 919 "moc.y"
3925{ yyval.string = straddSpc(yyvsp[-1].string,yyvsp[0].string); }
3926break;
3927case 52:
3928#line 920 "moc.y"
3929{ yyval.string = yyvsp[0].string; }
3930break;
3931case 53:
3932#line 923 "moc.y"
3933{ yyval.string = "char"; }
3934break;
3935case 54:
3936#line 924 "moc.y"
3937{ yyval.string = "short"; }
3938break;
3939case 55:
3940#line 925 "moc.y"
3941{ yyval.string = "int"; }
3942break;
3943case 56:
3944#line 926 "moc.y"
3945{ yyval.string = "long"; }
3946break;
3947case 57:
3948#line 927 "moc.y"
3949{ yyval.string = "signed"; }
3950break;
3951case 58:
3952#line 928 "moc.y"
3953{ yyval.string = "unsigned"; }
3954break;
3955case 59:
3956#line 929 "moc.y"
3957{ yyval.string = "float"; }
3958break;
3959case 60:
3960#line 930 "moc.y"
3961{ yyval.string = "double"; }
3962break;
3963case 61:
3964#line 931 "moc.y"
3965{ yyval.string = "void"; }
3966break;
3967case 62:
3968#line 935 "moc.y"
3969{ g->tmpExpression = rmWS( g->tmpExpression );
3970 yyval.string = stradd( "template<",
3971 g->tmpExpression, ">" ); }
3972break;
3973case 64:
3974#line 941 "moc.y"
3975{ templateClassOld = templateClass;
3976 templateClass = TRUE;
3977 }
3978break;
3979case 65:
3980#line 947 "moc.y"
3981{ yyval.string = "class"; }
3982break;
3983case 66:
3984#line 948 "moc.y"
3985{ yyval.string = "struct"; }
3986break;
3987case 67:
3988#line 951 "moc.y"
3989{ yyval.string = yyvsp[0].string; }
3990break;
3991case 68:
3992#line 953 "moc.y"
3993{ yyval.string = stradd( "::", yyvsp[0].string ); }
3994break;
3995case 69:
3996#line 957 "moc.y"
3997{ yyval.string = stradd( yyvsp[-2].string, "::", yyvsp[0].string );}
3998break;
3999case 70:
4000#line 958 "moc.y"
4001{ yyval.string = yyvsp[0].string; }
4002break;
4003case 71:
4004#line 962 "moc.y"
4005{ yyval.string = straddSpc(yyvsp[-1].string,yyvsp[0].string); }
4006break;
4007case 72:
4008#line 963 "moc.y"
4009{ yyval.string = stradd("enum ",yyvsp[0].string); }
4010break;
4011case 73:
4012#line 964 "moc.y"
4013{ yyval.string = stradd("union ",yyvsp[0].string); }
4014break;
4015case 74:
4016#line 969 "moc.y"
4017{ yyval.arg_list = yyvsp[-1].arg_list;}
4018break;
4019case 75:
4020#line 970 "moc.y"
4021{ yyval.arg_list = yyvsp[-2].arg_list;
4022 func_warn("Ellipsis not supported"
4023 " in signals and slots.\n"
4024 "Ellipsis argument ignored."); }
4025break;
4026case 76:
4027#line 976 "moc.y"
4028{ yyval.arg_list = tmpArgList; }
4029break;
4030case 77:
4031#line 977 "moc.y"
4032{ yyval.arg_list = yyvsp[0].arg_list; }
4033break;
4034case 78:
4035#line 980 "moc.y"
4036{ yyval.arg = 0; }
4037break;
4038case 81:
4039#line 985 "moc.y"
4040{ func_warn("Ellipsis not supported"
4041 " in signals and slots.\n"
4042 "Ellipsis argument ignored."); }
4043break;
4044case 82:
4045#line 993 "moc.y"
4046{ yyval.arg_list = addArg(yyvsp[0].arg); }
4047break;
4048case 83:
4049#line 994 "moc.y"
4050{ yyval.arg_list = addArg(yyvsp[0].arg); }
4051break;
4052case 84:
4053#line 998 "moc.y"
4054{ yyval.arg = new Argument(straddSpc(yyvsp[-1].string,yyvsp[0].string),""); }
4055break;
4056case 85:
4057#line 1000 "moc.y"
4058{ expLevel = 1; }
4059break;
4060case 86:
4061#line 1002 "moc.y"
4062{ yyval.arg = new Argument(straddSpc(yyvsp[-4].string,yyvsp[-3].string),"", 0, TRUE ); }
4063break;
4064case 87:
4065#line 1005 "moc.y"
4066{ yyval.arg = new Argument(straddSpc(yyvsp[-3].string,yyvsp[-2].string),yyvsp[0].string, yyvsp[-1].string); }
4067break;
4068case 88:
4069#line 1008 "moc.y"
4070{ expLevel = 1; }
4071break;
4072case 89:
4073#line 1010 "moc.y"
4074{ yyval.arg = new Argument(straddSpc(yyvsp[-6].string,yyvsp[-5].string),yyvsp[-3].string, yyvsp[-4].string, TRUE); }
4075break;
4076case 90:
4077#line 1014 "moc.y"
4078{ yyval.string = ""; }
4079break;
4080case 91:
4081#line 1015 "moc.y"
4082{ yyval.string = yyvsp[0].string; }
4083break;
4084case 92:
4085#line 1019 "moc.y"
4086{ yyval.string = straddSpc(yyvsp[-1].string,yyvsp[0].string); }
4087break;
4088case 93:
4089#line 1020 "moc.y"
4090{ expLevel = 1; }
4091break;
4092case 94:
4093#line 1022 "moc.y"
4094{ yyval.string = stradd( "[",
4095 g->tmpExpression =
4096 g->tmpExpression.stripWhiteSpace(), "]" ); }
4097break;
4098case 95:
4099#line 1025 "moc.y"
4100{ expLevel = 1; }
4101break;
4102case 96:
4103#line 1027 "moc.y"
4104{ yyval.string = stradd( yyvsp[-4].string,"[",
4105 g->tmpExpression =
4106 g->tmpExpression.stripWhiteSpace(),"]" ); }
4107break;
4108case 97:
4109#line 1030 "moc.y"
4110{ yyval.string = yyvsp[0].string; }
4111break;
4112case 98:
4113#line 1031 "moc.y"
4114{ yyval.string = yyvsp[-1].string; }
4115break;
4116case 99:
4117#line 1034 "moc.y"
4118{ yyval.string = ""; }
4119break;
4120case 100:
4121#line 1036 "moc.y"
4122{ yyval.string = straddSpc(yyvsp[-1].string,yyvsp[0].string);}
4123break;
4124case 101:
4125#line 1037 "moc.y"
4126{ expLevel = 1; }
4127break;
4128case 102:
4129#line 1039 "moc.y"
4130{ yyval.string = stradd( yyvsp[-4].string,"[",
4131 g->tmpExpression =
4132 g->tmpExpression.stripWhiteSpace(),"]" ); }
4133break;
4134case 103:
4135#line 1042 "moc.y"
4136{ yyval.string = yyvsp[-1].string; }
4137break;
4138case 105:
4139#line 1056 "moc.y"
4140{ tmpFunc->args = yyvsp[-6].arg_list;
4141 tmpFunc->qualifier = yyvsp[-4].string; }
4142break;
4143case 107:
4144#line 1062 "moc.y"
4145{ func_warn("Variable as signal or slot."); }
4146break;
4147case 108:
4148#line 1063 "moc.y"
4149{ expLevel=0; }
4150break;
4151case 109:
4152#line 1065 "moc.y"
4153{ skipFunc = TRUE; }
4154break;
4155case 110:
4156#line 1066 "moc.y"
4157{ expLevel=0; }
4158break;
4159case 111:
4160#line 1068 "moc.y"
4161{ skipFunc = TRUE; }
4162break;
4163case 112:
4164#line 1072 "moc.y"
4165{ expLevel = 1; }
4166break;
4167case 114:
4168#line 1074 "moc.y"
4169{ expLevel = 1; }
4170break;
4171case 116:
4172#line 1079 "moc.y"
4173{ yyval.string = ""; }
4174break;
4175case 117:
4176#line 1080 "moc.y"
4177{ yyval.string = yyvsp[0].string; }
4178break;
4179case 118:
4180#line 1083 "moc.y"
4181{ yyval.string = yyvsp[0].string; }
4182break;
4183case 119:
4184#line 1084 "moc.y"
4185{ yyval.string = straddSpc(yyvsp[-1].string,yyvsp[0].string);}
4186break;
4187case 120:
4188#line 1087 "moc.y"
4189{ yyval.string = straddSpc("*",yyvsp[0].string);}
4190break;
4191case 121:
4192#line 1088 "moc.y"
4193{ yyval.string = stradd("&",yyvsp[0].string);}
4194break;
4195case 122:
4196#line 1095 "moc.y"
4197{ yyval.string = ""; }
4198break;
4199case 123:
4200#line 1096 "moc.y"
4201{ yyval.string = yyvsp[0].string; }
4202break;
4203case 124:
4204#line 1099 "moc.y"
4205{ yyval.string = yyvsp[0].string; }
4206break;
4207case 125:
4208#line 1101 "moc.y"
4209{ yyval.string = straddSpc(yyvsp[-1].string,yyvsp[0].string); }
4210break;
4211case 126:
4212#line 1104 "moc.y"
4213{ yyval.string = "const"; }
4214break;
4215case 127:
4216#line 1105 "moc.y"
4217{ yyval.string = "volatile"; }
4218break;
4219case 131:
4220#line 1113 "moc.y"
4221{ BEGIN IN_FCT; fctLevel = 1;}
4222break;
4223case 132:
4224#line 1114 "moc.y"
4225{ BEGIN QT_DEF; }
4226break;
4227case 133:
4228#line 1121 "moc.y"
4229{ BEGIN IN_CLASS;
4230 classPLevel = 1;
4231 }
4232break;
4233case 134:
4234#line 1125 "moc.y"
4235{ BEGIN QT_DEF; }
4236break;
4237case 135:
4238#line 1126 "moc.y"
4239{ BEGIN QT_DEF; /* -- " -- */
4240 skipClass = TRUE; }
4241break;
4242case 136:
4243#line 1128 "moc.y"
4244{ BEGIN QT_DEF; /* -- " -- */
4245 skipClass = TRUE; }
4246break;
4247case 137:
4248#line 1130 "moc.y"
4249{ BEGIN QT_DEF; /* -- " -- */
4250 skipClass = TRUE; }
4251break;
4252case 138:
4253#line 1134 "moc.y"
4254{ BEGIN QT_DEF; /* catch ';' */
4255 skipClass = TRUE; }
4256break;
4257case 139:
4258#line 1136 "moc.y"
4259{ skipClass = TRUE;
4260 BEGIN GIMME_SEMICOLON; }
4261break;
4262case 143:
4263#line 1143 "moc.y"
4264{ yyval.string = ""; }
4265break;
4266case 145:
4267#line 1149 "moc.y"
4268{ g->className = yyvsp[0].string;
4269 if ( g->className == "QObject" )
4270 Q_OBJECTdetected = TRUE;
4271 }
4272break;
4273case 146:
4274#line 1155 "moc.y"
4275{ g->className = yyvsp[0].string;
4276 if ( g->className == "QObject" )
4277 Q_OBJECTdetected = TRUE;
4278 }
4279break;
4280case 147:
4281#line 1162 "moc.y"
4282{ g->superClassName = yyvsp[0].string; }
4283break;
4284case 148:
4285#line 1167 "moc.y"
4286{ templateClass = templateClassOld; }
4287break;
4288case 157:
4289#line 1190 "moc.y"
4290{ expLevel = 1; }
4291break;
4292case 159:
4293#line 1195 "moc.y"
4294{ yyval.string = 0; }
4295break;
4296case 160:
4297#line 1196 "moc.y"
4298{ yyval.string = yyvsp[0].string; }
4299break;
4300case 165:
4301#line 1208 "moc.y"
4302{ tmpAccess = yyvsp[0].access; }
4303break;
4304case 166:
4305#line 1209 "moc.y"
4306{ moc_err( "Missing access specifier"
4307 " before \"slots:\"." ); }
4308break;
4309case 167:
4310#line 1213 "moc.y"
4311{ BEGIN QT_DEF; }
4312break;
4313case 169:
4314#line 1215 "moc.y"
4315{ BEGIN QT_DEF; }
4316break;
4317case 171:
4318#line 1217 "moc.y"
4319{
4320 if ( tmpAccess )
4321 moc_warn("Q_OBJECT is not in the private"
4322 " section of the class.\n"
4323 "Q_OBJECT is a macro that resets"
4324 " access permission to \"private\".");
4325 Q_OBJECTdetected = TRUE;
4326 }
4327break;
4328case 172:
4329#line 1225 "moc.y"
4330{ tmpYYStart = YY_START;
4331 tmpPropOverride = FALSE;
4332 BEGIN IN_PROPERTY; }
4333break;
4334case 173:
4335#line 1228 "moc.y"
4336{
4337 BEGIN tmpYYStart;
4338 }
4339break;
4340case 175:
4341#line 1232 "moc.y"
4342{ tmpYYStart = YY_START;
4343 tmpPropOverride = TRUE;
4344 BEGIN IN_PROPERTY; }
4345break;
4346case 176:
4347#line 1235 "moc.y"
4348{
4349 BEGIN tmpYYStart;
4350 }
4351break;
4352case 178:
4353#line 1239 "moc.y"
4354{ tmpYYStart = YY_START; BEGIN IN_CLASSINFO; }
4355break;
4356case 179:
4357#line 1241 "moc.y"
4358{
4359 g->infos.append( new ClassInfo( yyvsp[-3].string, yyvsp[-1].string ) );
4360 BEGIN tmpYYStart;
4361 }
4362break;
4363case 181:
4364#line 1246 "moc.y"
4365{ tmpYYStart = YY_START; BEGIN IN_PROPERTY; }
4366break;
4367case 182:
4368#line 1247 "moc.y"
4369{
4370 Q_PROPERTYdetected = TRUE;
4371 BEGIN tmpYYStart;
4372 }
4373break;
4374case 184:
4375#line 1252 "moc.y"
4376{ tmpYYStart = YY_START; BEGIN IN_PROPERTY; }
4377break;
4378case 185:
4379#line 1253 "moc.y"
4380{
4381 Q_PROPERTYdetected = TRUE;
4382 BEGIN tmpYYStart;
4383 }
4384break;
4385case 187:
4386#line 1260 "moc.y"
4387{ moc_err( "Signals cannot "
4388 "have access specifiers" ); }
4389break;
4390case 189:
4391#line 1263 "moc.y"
4392{ if ( tmpAccess == Public && Q_PROPERTYdetected )
4393 BEGIN QT_DEF;
4394 else
4395 BEGIN IN_CLASS;
4396 suppress_func_warn = TRUE;
4397 }
4398break;
4399case 190:
4400#line 1270 "moc.y"
4401{
4402 suppress_func_warn = FALSE;
4403 }
4404break;
4405case 191:
4406#line 1273 "moc.y"
4407{ BEGIN IN_CLASS;
4408 if ( classPLevel != 1 )
4409 moc_warn( "unexpected access"
4410 "specifier" );
4411 }
4412break;
4413case 196:
4414#line 1288 "moc.y"
4415{ addMember( PropertyCandidateMember ); }
4416break;
4417case 201:
4418#line 1300 "moc.y"
4419{ addMember( SignalMember ); }
4420break;
4421case 206:
4422#line 1311 "moc.y"
4423{ addMember( SlotMember ); }
4424break;
4425case 209:
4426#line 1318 "moc.y"
4427{ yyval.string=yyvsp[0].string; }
4428break;
4429case 210:
4430#line 1321 "moc.y"
4431{ g->multipleSuperClasses.append( yyvsp[0].string ); }
4432break;
4433case 212:
4434#line 1326 "moc.y"
4435{ yyval.string = stradd( yyvsp[-3].string, "(", yyvsp[-1].string, ")" ); }
4436break;
4437case 213:
4438#line 1328 "moc.y"
4439{ yyval.string = stradd( yyvsp[-3].string, "(", yyvsp[-1].string, ")" ); }
4440break;
4441case 214:
4442#line 1331 "moc.y"
4443{yyval.string=yyvsp[0].string;}
4444break;
4445case 215:
4446#line 1332 "moc.y"
4447{yyval.string=yyvsp[0].string;}
4448break;
4449case 216:
4450#line 1333 "moc.y"
4451{yyval.string=yyvsp[0].string;}
4452break;
4453case 217:
4454#line 1334 "moc.y"
4455{yyval.string=yyvsp[0].string;}
4456break;
4457case 218:
4458#line 1335 "moc.y"
4459{yyval.string=yyvsp[0].string;}
4460break;
4461case 219:
4462#line 1336 "moc.y"
4463{yyval.string=yyvsp[0].string;}
4464break;
4465case 220:
4466#line 1337 "moc.y"
4467{yyval.string=yyvsp[0].string;}
4468break;
4469case 221:
4470#line 1338 "moc.y"
4471{yyval.string=yyvsp[0].string;}
4472break;
4473case 222:
4474#line 1339 "moc.y"
4475{yyval.string=yyvsp[0].string;}
4476break;
4477case 223:
4478#line 1340 "moc.y"
4479{yyval.string=yyvsp[0].string;}
4480break;
4481case 224:
4482#line 1343 "moc.y"
4483{ yyval.access=Private; }
4484break;
4485case 225:
4486#line 1344 "moc.y"
4487{ yyval.access=Protected; }
4488break;
4489case 226:
4490#line 1345 "moc.y"
4491{ yyval.access=Public; }
4492break;
4493case 227:
4494#line 1348 "moc.y"
4495{ }
4496break;
4497case 228:
4498#line 1349 "moc.y"
4499{ }
4500break;
4501case 270:
4502#line 1397 "moc.y"
4503{ tmpFunc->type = yyvsp[-1].string;
4504 tmpFunc->name = yyvsp[0].string; }
4505break;
4506case 271:
4507#line 1400 "moc.y"
4508{ tmpFunc->type = "int";
4509 tmpFunc->name = yyvsp[0].string;
4510 if ( tmpFunc->name == g->className )
4511 func_warn( "Constructors cannot be"
4512 " signals or slots.");
4513 }
4514break;
4515case 272:
4516#line 1407 "moc.y"
4517{ tmpFunc->type = "void";
4518 tmpFunc->name = "~";
4519 tmpFunc->name += yyvsp[0].string;
4520 func_warn( "Destructors cannot be"
4521 " signals or slots.");
4522 }
4523break;
4524case 273:
4525#line 1415 "moc.y"
4526{
4527 char *tmp =
4528 straddSpc(yyvsp[-4].string,yyvsp[-3].string,yyvsp[-2].string,yyvsp[-1].string);
4529 tmpFunc->type = rmWS(tmp);
4530 delete [] tmp;
4531 tmpFunc->name = yyvsp[0].string; }
4532break;
4533case 274:
4534#line 1422 "moc.y"
4535{ skipFunc = TRUE; }
4536break;
4537case 275:
4538#line 1424 "moc.y"
4539{ tmpFunc->type =
4540 straddSpc(yyvsp[-2].string,yyvsp[-1].string);
4541 tmpFunc->name = yyvsp[0].string; }
4542break;
4543case 276:
4544#line 1429 "moc.y"
4545{ tmpFunc->type =
4546 straddSpc(yyvsp[-3].string,yyvsp[-2].string,yyvsp[-1].string);
4547 tmpFunc->name = yyvsp[0].string; }
4548break;
4549case 277:
4550#line 1433 "moc.y"
4551{ operatorError(); }
4552break;
4553case 278:
4554#line 1435 "moc.y"
4555{ operatorError(); }
4556break;
4557case 279:
4558#line 1438 "moc.y"
4559{ operatorError(); }
4560break;
4561case 280:
4562#line 1440 "moc.y"
4563{ operatorError(); }
4564break;
4565case 281:
4566#line 1443 "moc.y"
4567{ operatorError(); }
4568break;
4569case 283:
4570#line 1449 "moc.y"
4571{ func_warn("Unexpected variable declaration."); }
4572break;
4573case 284:
4574#line 1452 "moc.y"
4575{ func_warn("Unexpected variable declaration."); }
4576break;
4577case 285:
4578#line 1454 "moc.y"
4579{ func_warn("Unexpected enum declaration."); }
4580break;
4581case 286:
4582#line 1456 "moc.y"
4583{ func_warn("Unexpected using declaration."); }
4584break;
4585case 287:
4586#line 1458 "moc.y"
4587{ func_warn("Unexpected using declaration."); }
4588break;
4589case 288:
4590#line 1460 "moc.y"
4591{ classPLevel++;
4592 moc_err("Unexpected namespace declaration."); }
4593break;
4594case 289:
4595#line 1463 "moc.y"
4596{ func_warn("Unexpected class declaration.");}
4597break;
4598case 290:
4599#line 1465 "moc.y"
4600{ func_warn("Unexpected class declaration.");
4601 BEGIN IN_FCT; fctLevel=1;
4602 }
4603break;
4604case 291:
4605#line 1468 "moc.y"
4606{ BEGIN QT_DEF; }
4607break;
4608case 295:
4609#line 1477 "moc.y"
4610{ }
4611break;
4612case 296:
4613#line 1478 "moc.y"
4614{ expLevel = 0; }
4615break;
4616case 298:
4617#line 1480 "moc.y"
4618{ expLevel = 0; }
4619break;
4620case 301:
4621#line 1485 "moc.y"
4622{ expLevel = 0; }
4623break;
4624case 306:
4625#line 1500 "moc.y"
4626{ BEGIN QT_DEF;
4627 if ( tmpAccess == Public) {
4628 tmpEnum->name = yyvsp[-4].string;
4629 addEnum();
4630 }
4631 }
4632break;
4633case 307:
4634#line 1507 "moc.y"
4635{ tmpEnum->clear();}
4636break;
4637case 309:
4638#line 1511 "moc.y"
4639{ }
4640break;
4641case 313:
4642#line 1519 "moc.y"
4643{ if ( tmpAccess == Public) tmpEnum->append( yyvsp[0].string ); }
4644break;
4645case 314:
4646#line 1520 "moc.y"
4647{ enumLevel=0; }
4648break;
4649case 315:
4650#line 1521 "moc.y"
4651{ if ( tmpAccess == Public) tmpEnum->append( yyvsp[-3].string ); }
4652break;
4653case 316:
4654#line 1525 "moc.y"
4655{
4656 g->propWrite = "";
4657 g->propRead = "";
4658 g->propOverride = tmpPropOverride;
4659 g->propReset = "";
4660 if ( g->propOverride ) {
4661 g->propStored = "";
4662 g->propDesignable = "";
4663 g->propScriptable = "";
4664 } else {
4665 g->propStored = "true";
4666 g->propDesignable = "true";
4667 g->propScriptable = "true";
4668 }
4669 }
4670break;
4671case 317:
4672#line 1541 "moc.y"
4673{
4674 if ( g->propRead.isEmpty() && !g->propOverride )
4675 moc_err( "A property must at least feature a read method." );
4676 checkPropertyName( yyvsp[-2].string );
4677 Q_PROPERTYdetected = TRUE;
4678 /* Avoid duplicates*/
4679 for( QPtrListIterator<Property> lit( g->props ); lit.current(); ++lit ) {
4680 if ( lit.current()->name == yyvsp[-2].string ) {
4681 if ( displayWarnings )
4682 moc_err( "Property '%s' defined twice.",
4683 (const char*)lit.current()->name );
4684 }
4685 }
4686 g->props.append( new Property( lineNo, yyvsp[-3].string, yyvsp[-2].string,
4687 g->propWrite, g->propRead, g->propReset,
4688 g->propStored, g->propDesignable,
4689 g->propScriptable, g->propOverride ) );
4690 }
4691break;
4692case 319:
4693#line 1562 "moc.y"
4694{ g->propRead = yyvsp[-1].string; }
4695break;
4696case 320:
4697#line 1563 "moc.y"
4698{ g->propWrite = yyvsp[-1].string; }
4699break;
4700case 321:
4701#line 1564 "moc.y"
4702{ g->propReset = yyvsp[-1].string; }
4703break;
4704case 322:
4705#line 1565 "moc.y"
4706{ g->propStored = yyvsp[-1].string; }
4707break;
4708case 323:
4709#line 1566 "moc.y"
4710{ g->propDesignable = yyvsp[-1].string; }
4711break;
4712case 324:
4713#line 1567 "moc.y"
4714{ g->propScriptable = yyvsp[-1].string; }
4715break;
4716case 325:
4717#line 1570 "moc.y"
4718{ }
4719break;
4720case 326:
4721#line 1571 "moc.y"
4722{ g->qtEnums.append( yyvsp[-1].string ); }
4723break;
4724case 327:
4725#line 1574 "moc.y"
4726{ }
4727break;
4728case 328:
4729#line 1575 "moc.y"
4730{ g->qtSets.append( yyvsp[-1].string ); }
4731break;
4732#line 4733 "y.tab.c"
4733 }
4734 yyssp -= yym;
4735 yystate = *yyssp;
4736 yyvsp -= yym;
4737 yym = yylhs[yyn];
4738 if (yystate == 0 && yym == 0)
4739 {
4740#if YYDEBUG
4741 if (yydebug)
4742 printf("%sdebug: after reduction, shifting from state 0 to\
4743 state %d\n", YYPREFIX, YYFINAL);
4744#endif
4745 yystate = YYFINAL;
4746 *++yyssp = YYFINAL;
4747 *++yyvsp = yyval;
4748 if (yychar < 0)
4749 {
4750 if ((yychar = yylex()) < 0) yychar = 0;
4751#if YYDEBUG
4752 if (yydebug)
4753 {
4754 yys = 0;
4755 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
4756 if (!yys) yys = "illegal-symbol";
4757 printf("%sdebug: state %d, reading %d (%s)\n",
4758 YYPREFIX, YYFINAL, yychar, yys);
4759 }
4760#endif
4761 }
4762 if (yychar == 0) goto yyaccept;
4763 goto yyloop;
4764 }
4765 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
4766 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
4767 yystate = yytable[yyn];
4768 else
4769 yystate = yydgoto[yym];
4770#if YYDEBUG
4771 if (yydebug)
4772 printf("%sdebug: after reduction, shifting from state %d \
4773to state %d\n", YYPREFIX, *yyssp, yystate);
4774#endif
4775 if (yyssp >= yyss + yystacksize - 1)
4776 {
4777 goto yyoverflow;
4778 }
4779 *++yyssp = yystate;
4780 *++yyvsp = yyval;
4781 goto yyloop;
4782yyoverflow:
4783 yyerror("yacc stack overflow");
4784yyabort:
4785 return (1);
4786yyaccept:
4787 return (0);
4788}
Note: See TracBrowser for help on using the repository browser.