1 /* A Bison parser, made by GNU Bison 2.3. */
2
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46 /* Identify Bison output. */
47 #define YYBISON 1
48
49 /* Bison version. */
50 #define YYBISON_VERSION "2.3"
51
52 /* Skeleton name. */
53 #define YYSKELETON_NAME "yacc.c"
54
55 /* Pure parsers. */
56 #define YYPURE 0
57
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
60
61
62
63 /* Tokens. */
64 #ifndef YYTOKENTYPE
65 # define YYTOKENTYPE
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
67 know about them. */
68 enum yytokentype {
69 TK_API = 258,
70 TK_AUTOPYNAME = 259,
71 TK_DEFDOCSTRFMT = 260,
72 TK_DEFDOCSTRSIG = 261,
73 TK_DEFENCODING = 262,
74 TK_PLUGIN = 263,
75 TK_VIRTERRORHANDLER = 264,
76 TK_EXPTYPEHINTCODE = 265,
77 TK_TYPEHINTCODE = 266,
78 TK_DOCSTRING = 267,
79 TK_EXTRACT = 268,
80 TK_ACCESSCODE = 269,
81 TK_GETCODE = 270,
82 TK_SETCODE = 271,
83 TK_PREINITCODE = 272,
84 TK_INITCODE = 273,
85 TK_POSTINITCODE = 274,
86 TK_FINALCODE = 275,
87 TK_UNITCODE = 276,
88 TK_UNITPOSTINCLUDECODE = 277,
89 TK_MODCODE = 278,
90 TK_TYPECODE = 279,
91 TK_COPYING = 280,
92 TK_MAPPEDTYPE = 281,
93 TK_CODELINE = 282,
94 TK_IF = 283,
95 TK_END = 284,
96 TK_NAME_VALUE = 285,
97 TK_PATH_VALUE = 286,
98 TK_STRING_VALUE = 287,
99 TK_VIRTUALCATCHERCODE = 288,
100 TK_TRAVERSECODE = 289,
101 TK_CLEARCODE = 290,
102 TK_GETBUFFERCODE = 291,
103 TK_RELEASEBUFFERCODE = 292,
104 TK_READBUFFERCODE = 293,
105 TK_WRITEBUFFERCODE = 294,
106 TK_SEGCOUNTCODE = 295,
107 TK_CHARBUFFERCODE = 296,
108 TK_PICKLECODE = 297,
109 TK_VIRTUALCALLCODE = 298,
110 TK_METHODCODE = 299,
111 TK_PREMETHODCODE = 300,
112 TK_INSTANCECODE = 301,
113 TK_FROMTYPE = 302,
114 TK_TOTYPE = 303,
115 TK_TOSUBCLASS = 304,
116 TK_INCLUDE = 305,
117 TK_IMPORT = 306,
118 TK_EXPHEADERCODE = 307,
119 TK_MODHEADERCODE = 308,
120 TK_TYPEHEADERCODE = 309,
121 TK_MODULE = 310,
122 TK_COMPOMODULE = 311,
123 TK_CLASS = 312,
124 TK_STRUCT = 313,
125 TK_PUBLIC = 314,
126 TK_PROTECTED = 315,
127 TK_PRIVATE = 316,
128 TK_SIGNALS = 317,
129 TK_SIGNAL_METHOD = 318,
130 TK_SLOTS = 319,
131 TK_SLOT_METHOD = 320,
132 TK_BOOL = 321,
133 TK_SHORT = 322,
134 TK_INT = 323,
135 TK_LONG = 324,
136 TK_FLOAT = 325,
137 TK_DOUBLE = 326,
138 TK_CHAR = 327,
139 TK_WCHAR_T = 328,
140 TK_VOID = 329,
141 TK_PYOBJECT = 330,
142 TK_PYTUPLE = 331,
143 TK_PYLIST = 332,
144 TK_PYDICT = 333,
145 TK_PYCALLABLE = 334,
146 TK_PYSLICE = 335,
147 TK_PYTYPE = 336,
148 TK_PYBUFFER = 337,
149 TK_VIRTUAL = 338,
150 TK_ENUM = 339,
151 TK_SIGNED = 340,
152 TK_UNSIGNED = 341,
153 TK_SCOPE = 342,
154 TK_LOGICAL_OR = 343,
155 TK_CONST = 344,
156 TK_STATIC = 345,
157 TK_PYSSIZET = 346,
158 TK_SIZET = 347,
159 TK_NUMBER_VALUE = 348,
160 TK_REAL_VALUE = 349,
161 TK_TYPEDEF = 350,
162 TK_NAMESPACE = 351,
163 TK_TIMELINE = 352,
164 TK_PLATFORMS = 353,
165 TK_FEATURE = 354,
166 TK_LICENSE = 355,
167 TK_QCHAR_VALUE = 356,
168 TK_TRUE_VALUE = 357,
169 TK_FALSE_VALUE = 358,
170 TK_NULL_VALUE = 359,
171 TK_OPERATOR = 360,
172 TK_THROW = 361,
173 TK_EXCEPTION = 362,
174 TK_RAISECODE = 363,
175 TK_EXPLICIT = 364,
176 TK_TEMPLATE = 365,
177 TK_FINAL = 366,
178 TK_ELLIPSIS = 367,
179 TK_DEFMETATYPE = 368,
180 TK_DEFSUPERTYPE = 369,
181 TK_PROPERTY = 370,
182 TK_HIDE_NS = 371,
183 TK_FORMAT = 372,
184 TK_GET = 373,
185 TK_ID = 374,
186 TK_KWARGS = 375,
187 TK_LANGUAGE = 376,
188 TK_LICENSEE = 377,
189 TK_NAME = 378,
190 TK_OPTIONAL = 379,
191 TK_ORDER = 380,
192 TK_REMOVELEADING = 381,
193 TK_SET = 382,
194 TK_SIGNATURE = 383,
195 TK_TIMESTAMP = 384,
196 TK_TYPE = 385,
197 TK_USEARGNAMES = 386,
198 TK_USELIMITEDAPI = 387,
199 TK_ALLRAISEPYEXC = 388,
200 TK_CALLSUPERINIT = 389,
201 TK_DEFERRORHANDLER = 390,
202 TK_VERSION = 391
203 };
204 #endif
205 /* Tokens. */
206 #define TK_API 258
207 #define TK_AUTOPYNAME 259
208 #define TK_DEFDOCSTRFMT 260
209 #define TK_DEFDOCSTRSIG 261
210 #define TK_DEFENCODING 262
211 #define TK_PLUGIN 263
212 #define TK_VIRTERRORHANDLER 264
213 #define TK_EXPTYPEHINTCODE 265
214 #define TK_TYPEHINTCODE 266
215 #define TK_DOCSTRING 267
216 #define TK_EXTRACT 268
217 #define TK_ACCESSCODE 269
218 #define TK_GETCODE 270
219 #define TK_SETCODE 271
220 #define TK_PREINITCODE 272
221 #define TK_INITCODE 273
222 #define TK_POSTINITCODE 274
223 #define TK_FINALCODE 275
224 #define TK_UNITCODE 276
225 #define TK_UNITPOSTINCLUDECODE 277
226 #define TK_MODCODE 278
227 #define TK_TYPECODE 279
228 #define TK_COPYING 280
229 #define TK_MAPPEDTYPE 281
230 #define TK_CODELINE 282
231 #define TK_IF 283
232 #define TK_END 284
233 #define TK_NAME_VALUE 285
234 #define TK_PATH_VALUE 286
235 #define TK_STRING_VALUE 287
236 #define TK_VIRTUALCATCHERCODE 288
237 #define TK_TRAVERSECODE 289
238 #define TK_CLEARCODE 290
239 #define TK_GETBUFFERCODE 291
240 #define TK_RELEASEBUFFERCODE 292
241 #define TK_READBUFFERCODE 293
242 #define TK_WRITEBUFFERCODE 294
243 #define TK_SEGCOUNTCODE 295
244 #define TK_CHARBUFFERCODE 296
245 #define TK_PICKLECODE 297
246 #define TK_VIRTUALCALLCODE 298
247 #define TK_METHODCODE 299
248 #define TK_PREMETHODCODE 300
249 #define TK_INSTANCECODE 301
250 #define TK_FROMTYPE 302
251 #define TK_TOTYPE 303
252 #define TK_TOSUBCLASS 304
253 #define TK_INCLUDE 305
254 #define TK_IMPORT 306
255 #define TK_EXPHEADERCODE 307
256 #define TK_MODHEADERCODE 308
257 #define TK_TYPEHEADERCODE 309
258 #define TK_MODULE 310
259 #define TK_COMPOMODULE 311
260 #define TK_CLASS 312
261 #define TK_STRUCT 313
262 #define TK_PUBLIC 314
263 #define TK_PROTECTED 315
264 #define TK_PRIVATE 316
265 #define TK_SIGNALS 317
266 #define TK_SIGNAL_METHOD 318
267 #define TK_SLOTS 319
268 #define TK_SLOT_METHOD 320
269 #define TK_BOOL 321
270 #define TK_SHORT 322
271 #define TK_INT 323
272 #define TK_LONG 324
273 #define TK_FLOAT 325
274 #define TK_DOUBLE 326
275 #define TK_CHAR 327
276 #define TK_WCHAR_T 328
277 #define TK_VOID 329
278 #define TK_PYOBJECT 330
279 #define TK_PYTUPLE 331
280 #define TK_PYLIST 332
281 #define TK_PYDICT 333
282 #define TK_PYCALLABLE 334
283 #define TK_PYSLICE 335
284 #define TK_PYTYPE 336
285 #define TK_PYBUFFER 337
286 #define TK_VIRTUAL 338
287 #define TK_ENUM 339
288 #define TK_SIGNED 340
289 #define TK_UNSIGNED 341
290 #define TK_SCOPE 342
291 #define TK_LOGICAL_OR 343
292 #define TK_CONST 344
293 #define TK_STATIC 345
294 #define TK_PYSSIZET 346
295 #define TK_SIZET 347
296 #define TK_NUMBER_VALUE 348
297 #define TK_REAL_VALUE 349
298 #define TK_TYPEDEF 350
299 #define TK_NAMESPACE 351
300 #define TK_TIMELINE 352
301 #define TK_PLATFORMS 353
302 #define TK_FEATURE 354
303 #define TK_LICENSE 355
304 #define TK_QCHAR_VALUE 356
305 #define TK_TRUE_VALUE 357
306 #define TK_FALSE_VALUE 358
307 #define TK_NULL_VALUE 359
308 #define TK_OPERATOR 360
309 #define TK_THROW 361
310 #define TK_EXCEPTION 362
311 #define TK_RAISECODE 363
312 #define TK_EXPLICIT 364
313 #define TK_TEMPLATE 365
314 #define TK_FINAL 366
315 #define TK_ELLIPSIS 367
316 #define TK_DEFMETATYPE 368
317 #define TK_DEFSUPERTYPE 369
318 #define TK_PROPERTY 370
319 #define TK_HIDE_NS 371
320 #define TK_FORMAT 372
321 #define TK_GET 373
322 #define TK_ID 374
323 #define TK_KWARGS 375
324 #define TK_LANGUAGE 376
325 #define TK_LICENSEE 377
326 #define TK_NAME 378
327 #define TK_OPTIONAL 379
328 #define TK_ORDER 380
329 #define TK_REMOVELEADING 381
330 #define TK_SET 382
331 #define TK_SIGNATURE 383
332 #define TK_TIMESTAMP 384
333 #define TK_TYPE 385
334 #define TK_USEARGNAMES 386
335 #define TK_USELIMITEDAPI 387
336 #define TK_ALLRAISEPYEXC 388
337 #define TK_CALLSUPERINIT 389
338 #define TK_DEFERRORHANDLER 390
339 #define TK_VERSION 391
340
341
342
343
344 /* Copy the first part of user declarations. */
345 #line 19 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
346
347 #include <stdlib.h>
348 #include <string.h>
349 #include <ctype.h>
350
351 #include "sip.h"
352
353
354 #define MAX_NESTED_IF 10
355 #define MAX_NESTED_SCOPE 10
356
357 #define inMainModule() (currentSpec->module == currentModule || currentModule->container != NULL)
358
359
360 static sipSpec *currentSpec; /* The current spec being parsed. */
361 static int strictParse; /* Set if the platform is enforced. */
362 static stringList *backstops; /* The list of backstops. */
363 static stringList *neededQualifiers; /* The list of required qualifiers. */
364 static stringList *excludedQualifiers; /* The list of excluded qualifiers. */
365 static moduleDef *currentModule; /* The current module being parsed. */
366 static mappedTypeDef *currentMappedType; /* The current mapped type. */
367 static enumDef *currentEnum; /* The current enum being parsed. */
368 static int sectionFlags; /* The current section flags. */
369 static int currentIsVirt; /* Set if the callable is virtual. */
370 static int currentCtorIsExplicit; /* Set if the ctor is explicit. */
371 static int currentIsStatic; /* Set if the current is static. */
372 static int currentIsSignal; /* Set if the current is Q_SIGNAL. */
373 static int currentIsSlot; /* Set if the current is Q_SLOT. */
374 static int currentIsTemplate; /* Set if the current is a template. */
375 static char *previousFile; /* The file just parsed. */
376 static parserContext currentContext; /* The current context. */
377 static int stackPtr; /* The stack pointer. */
378 static int skipStack[MAX_NESTED_IF]; /* Stack of skip flags. */
379 static classDef *scopeStack[MAX_NESTED_SCOPE]; /* The scope stack. */
380 static int sectFlagsStack[MAX_NESTED_SCOPE]; /* The section flags stack. */
381 static int currentScopeIdx; /* The scope stack index. */
382 static unsigned currentTimelineOrder; /* The current timeline order. */
383 static classList *currentSupers; /* The current super-class list. */
384 static platformDef *currentPlatforms; /* The current platforms list. */
385 static platformDef *platformStack[MAX_NESTED_IF]; /* Stack of platforms. */
386 static KwArgs defaultKwArgs; /* The default keyword arguments support. */
387 static int makeProtPublic; /* Treat protected items as public. */
388 static stringList **mainModuleSipFiles; /* The list of .sip files for the main module. */
389 static int parsingCSignature; /* An explicit C/C++ signature is being parsed. */
390
391
392 static const char *getPythonName(moduleDef *mod, optFlags *optflgs,
393 const char *cname);
394 static classDef *findClass(sipSpec *pt, ifaceFileType iftype,
395 apiVersionRangeDef *api_range, scopedNameDef *fqname, int tmpl_arg);
396 static classDef *findClassWithInterface(sipSpec *pt, ifaceFileDef *iff,
397 int tmpl_arg);
398 static classDef *newClass(sipSpec *pt, ifaceFileType iftype,
399 apiVersionRangeDef *api_range, scopedNameDef *snd,
400 const char *virt_error_handler, typeHintDef *typehint_in,
401 typeHintDef *typehint_out, const char *typehint_value);
402 static void finishClass(sipSpec *, moduleDef *, classDef *, optFlags *);
403 static exceptionDef *findException(sipSpec *pt, scopedNameDef *fqname, int new);
404 static mappedTypeDef *newMappedType(sipSpec *,argDef *, optFlags *);
405 static enumDef *newEnum(sipSpec *pt, moduleDef *mod, mappedTypeDef *mt_scope,
406 char *name, optFlags *of, int flags, int isscoped);
407 static void instantiateClassTemplate(sipSpec *pt, moduleDef *mod,
408 classDef *scope, scopedNameDef *fqname, classTmplDef *tcd,
409 templateDef *td, const char *pyname, int use_template_name,
410 docstringDef *docstring);
411 static void newTypedef(sipSpec *, moduleDef *, char *, argDef *, optFlags *,
412 docstringDef *);
413 static void newVar(sipSpec *pt, moduleDef *mod, char *name, int isstatic,
414 argDef *type, optFlags *of, codeBlock *acode, codeBlock *gcode,
415 codeBlock *scode, int section);
416 static void newCtor(moduleDef *, char *, int, signatureDef *, optFlags *,
417 codeBlock *, throwArgs *, signatureDef *, int,
418 docstringDef *, codeBlock *);
419 static void newFunction(sipSpec *, moduleDef *, classDef *, ifaceFileDef *,
420 mappedTypeDef *, int, int, int, int, int, char *, signatureDef *, int,
421 int, optFlags *, codeBlock *, codeBlock *, codeBlock *, throwArgs *,
422 signatureDef *, docstringDef *, int, codeBlock *);
423 static optFlag *findOptFlag(optFlags *flgs, const char *name);
424 static optFlag *getOptFlag(optFlags *flgs, const char *name, flagType ft);
425 static memberDef *findFunction(sipSpec *, moduleDef *, classDef *,
426 ifaceFileDef *, mappedTypeDef *, const char *, int, int, int);
427 static void checkAttributes(sipSpec *, moduleDef *, classDef *,
428 mappedTypeDef *, const char *, int);
429 static void newModule(FILE *fp, const char *filename);
430 static moduleDef *allocModule(void);
431 static void parseFile(FILE *fp, const char *name, moduleDef *prevmod,
432 int optional);
433 static void handleEOF(void);
434 static void handleEOM(void);
435 static qualDef *findQualifier(const char *name);
436 static const char *getInt(const char *cp, int *ip);
437 static scopedNameDef *text2scopedName(ifaceFileDef *scope, char *text);
438 static scopedNameDef *scopeScopedName(ifaceFileDef *scope,
439 scopedNameDef *name);
440 static void pushScope(classDef *);
441 static void popScope(void);
442 static classDef *currentScope(void);
443 static void newQualifier(moduleDef *, int, unsigned, int, const char *,
444 qualType);
445 static qualDef *allocQualifier(moduleDef *, int, unsigned, int, const char *,
446 qualType);
447 static void newImport(const char *filename);
448 static int timePeriod(const char *lname, const char *uname);
449 static int platOrFeature(char *name, int optnot);
450 static void addPlatform(qualDef *qd);
451 static int notSkipping(void);
452 static void getHooks(optFlags *,char **,char **);
453 static int getTransfer(optFlags *optflgs);
454 static int getReleaseGIL(optFlags *optflgs);
455 static int getHoldGIL(optFlags *optflgs);
456 static int getDeprecated(optFlags *optflgs);
457 static int getAllowNone(optFlags *optflgs);
458 static int getDisallowNone(optFlags *optflgs);
459 static const char *getVirtErrorHandler(optFlags *optflgs);
460 static const char *getTypeHintValue(optFlags *optflgs);
461 static void getTypeHints(optFlags *optflgs, typeHintDef **in,
462 typeHintDef **out);
463 static int getNoTypeHint(optFlags *optflgs);
464 static void templateSignature(signatureDef *sd, KwArgs kwargs, int result,
465 classTmplDef *tcd, templateDef *td, classDef *ncd,
466 scopedNameDef *type_names, scopedNameDef *type_values);
467 static void templateType(argDef *ad, classTmplDef *tcd, templateDef *td,
468 classDef *ncd, scopedNameDef *type_names, scopedNameDef *type_values);
469 static int search_back(const char *end, const char *start, const char *target);
470 static char *type2string(argDef *ad);
471 static char *scopedNameToString(scopedNameDef *name);
472 static void addUsedFromCode(sipSpec *pt, ifaceFileList **used, const char *sname);
473 static int sameName(scopedNameDef *snd, const char *sname);
474 static int stringFind(stringList *sl, const char *s);
475 static void setModuleName(sipSpec *pt, moduleDef *mod, const char *fullname);
476 static int foundInScope(scopedNameDef *fq_name, scopedNameDef *rel_name);
477 static void defineClass(scopedNameDef *snd, classList *supers, optFlags *of);
478 static classDef *completeClass(scopedNameDef *snd, optFlags *of, int has_def);
479 static memberDef *instantiateTemplateMethods(memberDef *tmd, moduleDef *mod);
480 static void instantiateTemplateEnums(sipSpec *pt, classTmplDef *tcd,
481 templateDef *td, classDef *cd, ifaceFileList **used,
482 scopedNameDef *type_names, scopedNameDef *type_values);
483 static void instantiateTemplateVars(sipSpec *pt, classTmplDef *tcd,
484 templateDef *td, classDef *cd, ifaceFileList **used,
485 scopedNameDef *type_names, scopedNameDef *type_values);
486 static void instantiateTemplateTypedefs(sipSpec *pt, classTmplDef *tcd,
487 templateDef *td, classDef *cd, scopedNameDef *type_names,
488 scopedNameDef *type_values);
489 static overDef *instantiateTemplateOverloads(sipSpec *pt, overDef *tod,
490 memberDef *tmethods, memberDef *methods, classTmplDef *tcd,
491 templateDef *td, classDef *cd, ifaceFileList **used,
492 scopedNameDef *type_names, scopedNameDef *type_values);
493 static void resolveAnyTypedef(sipSpec *pt, argDef *ad);
494 static void addTypedef(sipSpec *pt, typedefDef *tdd);
495 static void addVariable(sipSpec *pt, varDef *vd);
496 static void applyTypeFlags(moduleDef *mod, argDef *ad, optFlags *flags);
497 static Format convertFormat(const char *format);
498 static Signature convertSignature(const char *signature);
499 static argType convertEncoding(const char *encoding);
500 static apiVersionRangeDef *getAPIRange(optFlags *optflgs);
501 static apiVersionRangeDef *convertAPIRange(moduleDef *mod, nameDef *name,
502 int from, int to);
503 static char *convertFeaturedString(char *fs);
504 static KwArgs keywordArgs(moduleDef *mod, optFlags *optflgs, signatureDef *sd,
505 int need_name);
506 static char *strip(char *s);
507 static int isEnabledFeature(const char *name);
508 static void addProperty(sipSpec *pt, moduleDef *mod, classDef *cd,
509 const char *name, const char *get, const char *set,
510 docstringDef *docstring);
511 static moduleDef *configureModule(sipSpec *pt, moduleDef *module,
512 const char *filename, const char *name, int c_module, KwArgs kwargs,
513 int use_arg_names, int use_limited_api, int call_super_init,
514 int all_raise_py_exc, const char *def_error_handler,
515 docstringDef *docstring);
516 static void addAutoPyName(moduleDef *mod, const char *remove_leading);
517 static KwArgs convertKwArgs(const char *kwargs);
518 static void checkAnnos(optFlags *annos, const char *valid[]);
519 static void appendCodeBlock(codeBlockList **headp, codeBlock *cb);
520 static void handleKeepReference(optFlags *optflgs, argDef *ad, moduleDef *mod);
521 static void mappedTypeAnnos(mappedTypeDef *mtd, optFlags *optflgs);
522 static void add_new_deref(argDef *new, argDef *orig, int isconst);
523 static void add_derefs(argDef *dst, argDef *src);
524 static int isBackstop(qualDef *qd);
525 static void checkEllipsis(signatureDef *sd);
526 static scopedNameDef *fullyQualifiedName(scopedNameDef *snd);
527
528
529 /* Enabling traces. */
530 #ifndef YYDEBUG
531 # define YYDEBUG 0
532 #endif
533
534 /* Enabling verbose error messages. */
535 #ifdef YYERROR_VERBOSE
536 # undef YYERROR_VERBOSE
537 # define YYERROR_VERBOSE 1
538 #else
539 # define YYERROR_VERBOSE 0
540 #endif
541
542 /* Enabling the token table. */
543 #ifndef YYTOKEN_TABLE
544 # define YYTOKEN_TABLE 0
545 #endif
546
547 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
548 typedef union YYSTYPE
549 #line 202 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
550 {
551 char qchar;
552 char *text;
553 long number;
554 double real;
555 argDef memArg;
556 signatureDef signature;
557 signatureDef *optsignature;
558 throwArgs *throwlist;
559 codeBlock *codeb;
560 docstringDef *docstr;
561 valueDef value;
562 valueDef *valp;
563 optFlags optflags;
564 optFlag flag;
565 scopedNameDef *scpvalp;
566 fcallDef fcall;
567 int boolean;
568 exceptionDef exceptionbase;
569 classDef *klass;
570 apiCfg api;
571 autoPyNameCfg autopyname;
572 compModuleCfg compmodule;
573 defDocstringFmtCfg defdocstringfmt;
574 defDocstringSigCfg defdocstringsig;
575 defEncodingCfg defencoding;
576 defMetatypeCfg defmetatype;
577 defSupertypeCfg defsupertype;
578 hiddenNsCfg hiddenns;
579 exceptionCfg exception;
580 docstringCfg docstring;
581 extractCfg extract;
582 featureCfg feature;
583 licenseCfg license;
584 importCfg import;
585 includeCfg include;
586 moduleCfg module;
587 pluginCfg plugin;
588 propertyCfg property;
589 variableCfg variable;
590 vehCfg veh;
591 int token;
592 }
593 /* Line 193 of yacc.c. */
594 #line 595 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/parser.c"
595 YYSTYPE;
596 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
597 # define YYSTYPE_IS_DECLARED 1
598 # define YYSTYPE_IS_TRIVIAL 1
599 #endif
600
601
602
603 /* Copy the second part of user declarations. */
604
605
606 /* Line 216 of yacc.c. */
607 #line 608 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/parser.c"
608
609 #ifdef short
610 # undef short
611 #endif
612
613 #ifdef YYTYPE_UINT8
614 typedef YYTYPE_UINT8 yytype_uint8;
615 #else
616 typedef unsigned char yytype_uint8;
617 #endif
618
619 #ifdef YYTYPE_INT8
620 typedef YYTYPE_INT8 yytype_int8;
621 #elif (defined __STDC__ || defined __C99__FUNC__ \
622 || defined __cplusplus || defined _MSC_VER)
623 typedef signed char yytype_int8;
624 #else
625 typedef short int yytype_int8;
626 #endif
627
628 #ifdef YYTYPE_UINT16
629 typedef YYTYPE_UINT16 yytype_uint16;
630 #else
631 typedef unsigned short int yytype_uint16;
632 #endif
633
634 #ifdef YYTYPE_INT16
635 typedef YYTYPE_INT16 yytype_int16;
636 #else
637 typedef short int yytype_int16;
638 #endif
639
640 #ifndef YYSIZE_T
641 # ifdef __SIZE_TYPE__
642 # define YYSIZE_T __SIZE_TYPE__
643 # elif defined size_t
644 # define YYSIZE_T size_t
645 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
646 || defined __cplusplus || defined _MSC_VER)
647 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
648 # define YYSIZE_T size_t
649 # else
650 # define YYSIZE_T unsigned int
651 # endif
652 #endif
653
654 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
655
656 #ifndef YY_
657 # if defined YYENABLE_NLS && YYENABLE_NLS
658 # if ENABLE_NLS
659 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
660 # define YY_(msgid) dgettext ("bison-runtime", msgid)
661 # endif
662 # endif
663 # ifndef YY_
664 # define YY_(msgid) msgid
665 # endif
666 #endif
667
668 /* Suppress unused-variable warnings by "using" E. */
669 #if ! defined lint || defined __GNUC__
670 # define YYUSE(e) ((void) (e))
671 #else
672 # define YYUSE(e) /* empty */
673 #endif
674
675 /* Identity function, used to suppress warnings about constant conditions. */
676 #ifndef lint
677 # define YYID(n) (n)
678 #else
679 #if (defined __STDC__ || defined __C99__FUNC__ \
680 || defined __cplusplus || defined _MSC_VER)
681 static int
YYID(int i)682 YYID (int i)
683 #else
684 static int
685 YYID (i)
686 int i;
687 #endif
688 {
689 return i;
690 }
691 #endif
692
693 #if ! defined yyoverflow || YYERROR_VERBOSE
694
695 /* The parser invokes alloca or malloc; define the necessary symbols. */
696
697 # ifdef YYSTACK_USE_ALLOCA
698 # if YYSTACK_USE_ALLOCA
699 # ifdef __GNUC__
700 # define YYSTACK_ALLOC __builtin_alloca
701 # elif defined __BUILTIN_VA_ARG_INCR
702 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
703 # elif defined _AIX
704 # define YYSTACK_ALLOC __alloca
705 # elif defined _MSC_VER
706 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
707 # define alloca _alloca
708 # else
709 # define YYSTACK_ALLOC alloca
710 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
711 || defined __cplusplus || defined _MSC_VER)
712 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
713 # ifndef _STDLIB_H
714 # define _STDLIB_H 1
715 # endif
716 # endif
717 # endif
718 # endif
719 # endif
720
721 # ifdef YYSTACK_ALLOC
722 /* Pacify GCC's `empty if-body' warning. */
723 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
724 # ifndef YYSTACK_ALLOC_MAXIMUM
725 /* The OS might guarantee only one guard page at the bottom of the stack,
726 and a page size can be as small as 4096 bytes. So we cannot safely
727 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
728 to allow for a few compiler-allocated temporary stack slots. */
729 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
730 # endif
731 # else
732 # define YYSTACK_ALLOC YYMALLOC
733 # define YYSTACK_FREE YYFREE
734 # ifndef YYSTACK_ALLOC_MAXIMUM
735 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
736 # endif
737 # if (defined __cplusplus && ! defined _STDLIB_H \
738 && ! ((defined YYMALLOC || defined malloc) \
739 && (defined YYFREE || defined free)))
740 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
741 # ifndef _STDLIB_H
742 # define _STDLIB_H 1
743 # endif
744 # endif
745 # ifndef YYMALLOC
746 # define YYMALLOC malloc
747 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
748 || defined __cplusplus || defined _MSC_VER)
749 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
750 # endif
751 # endif
752 # ifndef YYFREE
753 # define YYFREE free
754 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
755 || defined __cplusplus || defined _MSC_VER)
756 void free (void *); /* INFRINGES ON USER NAME SPACE */
757 # endif
758 # endif
759 # endif
760 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
761
762
763 #if (! defined yyoverflow \
764 && (! defined __cplusplus \
765 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
766
767 /* A type that is properly aligned for any stack member. */
768 union yyalloc
769 {
770 yytype_int16 yyss;
771 YYSTYPE yyvs;
772 };
773
774 /* The size of the maximum gap between one aligned stack and the next. */
775 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
776
777 /* The size of an array large to enough to hold all stacks, each with
778 N elements. */
779 # define YYSTACK_BYTES(N) \
780 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
781 + YYSTACK_GAP_MAXIMUM)
782
783 /* Copy COUNT objects from FROM to TO. The source and destination do
784 not overlap. */
785 # ifndef YYCOPY
786 # if defined __GNUC__ && 1 < __GNUC__
787 # define YYCOPY(To, From, Count) \
788 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
789 # else
790 # define YYCOPY(To, From, Count) \
791 do \
792 { \
793 YYSIZE_T yyi; \
794 for (yyi = 0; yyi < (Count); yyi++) \
795 (To)[yyi] = (From)[yyi]; \
796 } \
797 while (YYID (0))
798 # endif
799 # endif
800
801 /* Relocate STACK from its old location to the new one. The
802 local variables YYSIZE and YYSTACKSIZE give the old and new number of
803 elements in the stack, and YYPTR gives the new location of the
804 stack. Advance YYPTR to a properly aligned location for the next
805 stack. */
806 # define YYSTACK_RELOCATE(Stack) \
807 do \
808 { \
809 YYSIZE_T yynewbytes; \
810 YYCOPY (&yyptr->Stack, Stack, yysize); \
811 Stack = &yyptr->Stack; \
812 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
813 yyptr += yynewbytes / sizeof (*yyptr); \
814 } \
815 while (YYID (0))
816
817 #endif
818
819 /* YYFINAL -- State number of the termination state. */
820 #define YYFINAL 4
821 /* YYLAST -- Last index in YYTABLE. */
822 #define YYLAST 1375
823
824 /* YYNTOKENS -- Number of terminals. */
825 #define YYNTOKENS 159
826 /* YYNNTS -- Number of nonterminals. */
827 #define YYNNTS 238
828 /* YYNRULES -- Number of rules. */
829 #define YYNRULES 553
830 /* YYNRULES -- Number of states. */
831 #define YYNSTATES 953
832
833 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
834 #define YYUNDEFTOK 2
835 #define YYMAXUTOK 391
836
837 #define YYTRANSLATE(YYX) \
838 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
839
840 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
841 static const yytype_uint8 yytranslate[] =
842 {
843 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
844 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
845 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
846 2, 2, 2, 144, 2, 2, 2, 157, 149, 2,
847 137, 138, 147, 146, 139, 145, 2, 148, 2, 2,
848 2, 2, 2, 2, 2, 2, 2, 2, 154, 143,
849 152, 140, 153, 2, 2, 2, 2, 2, 2, 2,
850 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
851 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
852 2, 155, 2, 156, 158, 2, 2, 2, 2, 2,
853 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
854 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
855 2, 2, 2, 141, 150, 142, 151, 2, 2, 2,
856 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
857 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
858 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
859 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
860 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
861 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
862 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
863 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
864 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
865 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
866 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
867 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
868 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
869 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
870 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
871 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
872 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
873 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
874 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
875 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
876 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
877 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
878 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
879 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
880 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
881 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
882 135, 136
883 };
884
885 #if YYDEBUG
886 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
887 YYRHS. */
888 static const yytype_uint16 yyprhs[] =
889 {
890 0, 0, 3, 5, 8, 9, 12, 14, 16, 18,
891 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
892 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
893 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
894 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
895 100, 103, 105, 109, 111, 115, 119, 122, 124, 128,
896 130, 134, 138, 141, 143, 147, 149, 153, 157, 160,
897 162, 166, 168, 172, 176, 180, 182, 186, 188, 192,
898 196, 201, 203, 207, 211, 215, 221, 222, 226, 231,
899 233, 236, 238, 240, 242, 244, 247, 248, 254, 255,
900 262, 267, 269, 272, 274, 276, 278, 280, 283, 286,
901 288, 290, 292, 307, 308, 314, 315, 319, 321, 324,
902 325, 331, 333, 336, 338, 341, 343, 347, 349, 353,
903 357, 358, 364, 366, 369, 371, 372, 378, 380, 383,
904 387, 392, 394, 398, 400, 403, 404, 406, 410, 412,
905 416, 420, 424, 428, 432, 435, 437, 441, 443, 447,
906 451, 454, 456, 460, 462, 466, 470, 473, 475, 479,
907 481, 485, 489, 493, 495, 499, 501, 505, 509, 510,
908 515, 517, 520, 522, 524, 526, 530, 531, 534, 538,
909 540, 544, 548, 552, 556, 560, 564, 568, 572, 576,
910 577, 582, 584, 587, 589, 591, 593, 595, 597, 599,
911 600, 602, 605, 607, 611, 613, 617, 621, 625, 628,
912 630, 634, 636, 640, 644, 647, 650, 653, 656, 659,
913 662, 665, 668, 671, 674, 677, 680, 683, 686, 689,
914 692, 695, 698, 701, 704, 707, 710, 713, 716, 719,
915 722, 726, 728, 732, 736, 740, 741, 743, 747, 749,
916 753, 757, 761, 762, 764, 768, 770, 774, 776, 780,
917 784, 788, 791, 793, 796, 797, 807, 808, 810, 812,
918 813, 815, 816, 818, 820, 823, 825, 827, 832, 833,
919 835, 836, 839, 840, 843, 845, 849, 851, 853, 855,
920 857, 859, 861, 862, 864, 866, 868, 870, 872, 874,
921 878, 879, 883, 886, 888, 890, 894, 896, 898, 900,
922 902, 907, 910, 912, 914, 916, 918, 920, 922, 923,
923 925, 929, 936, 949, 950, 951, 960, 961, 965, 970,
924 971, 972, 981, 982, 985, 987, 991, 994, 995, 997,
925 999, 1001, 1002, 1006, 1007, 1009, 1012, 1014, 1016, 1018,
926 1020, 1022, 1024, 1026, 1028, 1030, 1032, 1034, 1036, 1038,
927 1040, 1042, 1044, 1046, 1048, 1050, 1052, 1054, 1056, 1058,
928 1060, 1062, 1064, 1066, 1068, 1071, 1074, 1077, 1081, 1085,
929 1089, 1092, 1096, 1100, 1102, 1106, 1110, 1114, 1118, 1119,
930 1124, 1126, 1129, 1131, 1133, 1135, 1137, 1139, 1140, 1142,
931 1143, 1147, 1149, 1161, 1162, 1166, 1168, 1180, 1181, 1182,
932 1189, 1190, 1191, 1199, 1217, 1225, 1243, 1260, 1262, 1264,
933 1266, 1268, 1270, 1272, 1274, 1276, 1279, 1282, 1285, 1288,
934 1291, 1294, 1297, 1300, 1303, 1306, 1310, 1314, 1316, 1319,
935 1322, 1324, 1327, 1330, 1333, 1335, 1338, 1339, 1341, 1342,
936 1344, 1345, 1348, 1349, 1353, 1355, 1359, 1361, 1365, 1367,
937 1373, 1375, 1377, 1378, 1381, 1382, 1385, 1386, 1389, 1390,
938 1393, 1395, 1396, 1398, 1402, 1405, 1406, 1410, 1411, 1415,
939 1417, 1418, 1422, 1424, 1426, 1428, 1429, 1433, 1435, 1441,
940 1442, 1446, 1448, 1451, 1453, 1455, 1458, 1461, 1464, 1469,
941 1473, 1477, 1478, 1480, 1481, 1485, 1488, 1490, 1495, 1498,
942 1501, 1503, 1505, 1508, 1510, 1512, 1515, 1518, 1522, 1524,
943 1526, 1528, 1531, 1534, 1536, 1538, 1540, 1542, 1544, 1546,
944 1548, 1550, 1552, 1554, 1556, 1558, 1560, 1562, 1564, 1568,
945 1569, 1574, 1575, 1577
946 };
947
948 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
949 static const yytype_int16 yyrhs[] =
950 {
951 160, 0, -1, 161, -1, 160, 161, -1, -1, 162,
952 163, -1, 177, -1, 185, -1, 239, -1, 264, -1,
953 165, -1, 169, -1, 173, -1, 227, -1, 231, -1,
954 265, -1, 286, -1, 298, -1, 210, -1, 235, -1,
955 260, -1, 256, -1, 282, -1, 223, -1, 194, -1,
956 246, -1, 279, -1, 266, -1, 206, -1, 281, -1,
957 283, -1, 214, -1, 287, -1, 284, -1, 285, -1,
958 181, -1, 196, -1, 164, -1, 218, -1, 222, -1,
959 202, -1, 326, -1, 332, -1, 329, -1, 188, -1,
960 325, -1, 304, -1, 361, -1, 385, -1, 267, -1,
961 5, 166, -1, 32, -1, 137, 167, 138, -1, 168,
962 -1, 167, 139, 168, -1, 123, 140, 32, -1, 6,
963 170, -1, 32, -1, 137, 171, 138, -1, 172, -1,
964 171, 139, 172, -1, 123, 140, 32, -1, 7, 174,
965 -1, 32, -1, 137, 175, 138, -1, 176, -1, 175,
966 139, 176, -1, 123, 140, 32, -1, 8, 178, -1,
967 30, -1, 137, 179, 138, -1, 180, -1, 179, 139,
968 180, -1, 123, 140, 30, -1, 9, 182, 302, -1,
969 30, -1, 137, 183, 138, -1, 184, -1, 183, 139,
970 184, -1, 123, 140, 30, -1, 3, 137, 186, 138,
971 -1, 187, -1, 186, 139, 187, -1, 123, 140, 349,
972 -1, 136, 140, 93, -1, 107, 319, 189, 366, 190,
973 -1, -1, 137, 319, 138, -1, 141, 191, 142, 143,
974 -1, 192, -1, 191, 192, -1, 218, -1, 222, -1,
975 193, -1, 267, -1, 108, 302, -1, -1, 26, 393,
976 366, 195, 198, -1, -1, 331, 26, 393, 366, 197,
977 198, -1, 141, 199, 142, 143, -1, 200, -1, 199,
978 200, -1, 218, -1, 222, -1, 267, -1, 280, -1,
979 47, 302, -1, 48, 302, -1, 276, -1, 304, -1,
980 201, -1, 90, 389, 30, 137, 374, 138, 363, 395,
981 366, 359, 143, 297, 372, 371, -1, -1, 96, 30,
982 203, 204, 143, -1, -1, 141, 205, 142, -1, 164,
983 -1, 205, 164, -1, -1, 98, 207, 141, 208, 142,
984 -1, 209, -1, 208, 209, -1, 30, -1, 99, 211,
985 -1, 30, -1, 137, 212, 138, -1, 213, -1, 212,
986 139, 213, -1, 123, 140, 349, -1, -1, 97, 215,
987 141, 216, 142, -1, 217, -1, 216, 217, -1, 30,
988 -1, -1, 28, 137, 219, 221, 138, -1, 30, -1,
989 144, 30, -1, 220, 88, 30, -1, 220, 88, 144,
990 30, -1, 220, -1, 307, 145, 307, -1, 29, -1,
991 100, 224, -1, -1, 32, -1, 137, 225, 138, -1,
992 226, -1, 225, 139, 226, -1, 130, 140, 32, -1,
993 122, 140, 32, -1, 128, 140, 32, -1, 129, 140,
994 32, -1, 113, 228, -1, 254, -1, 137, 229, 138,
995 -1, 230, -1, 229, 139, 230, -1, 123, 140, 254,
996 -1, 114, 232, -1, 254, -1, 137, 233, 138, -1,
997 234, -1, 233, 139, 234, -1, 123, 140, 254, -1,
998 116, 236, -1, 319, -1, 137, 237, 138, -1, 238,
999 -1, 237, 139, 238, -1, 123, 140, 319, -1, 56,
1000 240, 243, -1, 254, -1, 137, 241, 138, -1, 242,
1001 -1, 241, 139, 242, -1, 123, 140, 254, -1, -1,
1002 141, 244, 142, 143, -1, 245, -1, 244, 245, -1,
1003 218, -1, 222, -1, 293, -1, 55, 247, 251, -1,
1004 -1, 254, 248, -1, 137, 249, 138, -1, 250, -1,
1005 249, 139, 250, -1, 120, 140, 32, -1, 121, 140,
1006 32, -1, 123, 140, 254, -1, 131, 140, 322, -1,
1007 132, 140, 322, -1, 133, 140, 322, -1, 134, 140,
1008 322, -1, 135, 140, 30, -1, -1, 141, 252, 142,
1009 143, -1, 253, -1, 252, 253, -1, 218, -1, 222,
1010 -1, 289, -1, 293, -1, 30, -1, 31, -1, -1,
1011 93, -1, 50, 257, -1, 31, -1, 137, 258, 138,
1012 -1, 259, -1, 258, 139, 259, -1, 123, 140, 31,
1013 -1, 124, 140, 322, -1, 51, 261, -1, 31, -1,
1014 137, 262, 138, -1, 263, -1, 262, 139, 263, -1,
1015 123, 140, 31, -1, 25, 302, -1, 52, 302, -1,
1016 53, 302, -1, 54, 302, -1, 34, 302, -1, 35,
1017 302, -1, 36, 302, -1, 37, 302, -1, 38, 302,
1018 -1, 39, 302, -1, 40, 302, -1, 41, 302, -1,
1019 46, 302, -1, 42, 302, -1, 20, 302, -1, 23,
1020 302, -1, 24, 302, -1, 17, 302, -1, 18, 302,
1021 -1, 19, 302, -1, 21, 302, -1, 22, 302, -1,
1022 10, 302, -1, 11, 302, -1, 11, 302, -1, 4,
1023 290, -1, 137, 291, 138, -1, 292, -1, 291, 139,
1024 292, -1, 126, 140, 32, -1, 12, 294, 302, -1,
1025 -1, 32, -1, 137, 295, 138, -1, 296, -1, 295,
1026 139, 296, -1, 117, 140, 32, -1, 128, 140, 32,
1027 -1, -1, 293, -1, 13, 299, 302, -1, 30, -1,
1028 137, 300, 138, -1, 301, -1, 300, 139, 301, -1,
1029 119, 140, 30, -1, 125, 140, 93, -1, 303, 29,
1030 -1, 27, -1, 303, 27, -1, -1, 84, 306, 307,
1031 366, 305, 141, 308, 142, 143, -1, -1, 57, -1,
1032 58, -1, -1, 30, -1, -1, 309, -1, 310, -1,
1033 309, 310, -1, 218, -1, 222, -1, 30, 312, 366,
1034 311, -1, -1, 139, -1, -1, 140, 317, -1, -1,
1035 140, 314, -1, 317, -1, 314, 315, 317, -1, 145,
1036 -1, 146, -1, 147, -1, 148, -1, 149, -1, 150,
1037 -1, -1, 144, -1, 151, -1, 145, -1, 146, -1,
1038 147, -1, 149, -1, 318, 316, 323, -1, -1, 137,
1039 319, 138, -1, 87, 320, -1, 320, -1, 321, -1,
1040 320, 87, 321, -1, 30, -1, 102, -1, 103, -1,
1041 319, -1, 393, 137, 324, 138, -1, 141, 142, -1,
1042 94, -1, 93, -1, 322, -1, 104, -1, 32, -1,
1043 101, -1, -1, 314, -1, 324, 139, 314, -1, 95,
1044 389, 30, 366, 143, 297, -1, 95, 389, 137, 147,
1045 30, 138, 137, 394, 138, 366, 143, 297, -1, -1,
1046 -1, 58, 319, 327, 335, 366, 328, 339, 143, -1,
1047 -1, 331, 330, 332, -1, 110, 152, 394, 153, -1,
1048 -1, -1, 57, 319, 333, 335, 366, 334, 339, 143,
1049 -1, -1, 154, 336, -1, 337, -1, 336, 139, 337,
1050 -1, 338, 319, -1, -1, 59, -1, 60, -1, 61,
1051 -1, -1, 141, 340, 142, -1, -1, 341, -1, 340,
1052 341, -1, 218, -1, 222, -1, 202, -1, 326, -1,
1053 332, -1, 329, -1, 188, -1, 325, -1, 304, -1,
1054 342, -1, 293, -1, 280, -1, 267, -1, 268, -1,
1055 269, -1, 270, -1, 271, -1, 272, -1, 273, -1,
1056 274, -1, 275, -1, 276, -1, 277, -1, 278, -1,
1057 288, -1, 354, -1, 351, -1, 377, -1, 49, 302,
1058 -1, 48, 302, -1, 47, 302, -1, 59, 350, 154,
1059 -1, 60, 350, 154, -1, 61, 350, 154, -1, 62,
1060 154, -1, 115, 343, 346, -1, 137, 344, 138, -1,
1061 345, -1, 344, 139, 345, -1, 118, 140, 30, -1,
1062 123, 140, 349, -1, 127, 140, 30, -1, -1, 141,
1063 347, 142, 143, -1, 348, -1, 347, 348, -1, 218,
1064 -1, 222, -1, 293, -1, 30, -1, 32, -1, -1,
1065 64, -1, -1, 83, 352, 353, -1, 353, -1, 151,
1066 30, 137, 138, 395, 365, 366, 143, 372, 371, 373,
1067 -1, -1, 109, 355, 356, -1, 356, -1, 30, 137,
1068 374, 138, 395, 366, 357, 143, 297, 372, 371, -1,
1069 -1, -1, 155, 358, 137, 374, 138, 156, -1, -1,
1070 -1, 155, 360, 389, 137, 374, 138, 156, -1, 389,
1071 30, 137, 374, 138, 363, 364, 395, 365, 366, 359,
1072 143, 297, 372, 371, 373, 370, -1, 389, 105, 140,
1073 137, 389, 138, 143, -1, 389, 105, 362, 137, 374,
1074 138, 363, 364, 395, 365, 366, 359, 143, 372, 371,
1075 373, 370, -1, 105, 389, 137, 374, 138, 363, 364,
1076 395, 365, 366, 359, 143, 372, 371, 373, 370, -1,
1077 146, -1, 145, -1, 147, -1, 148, -1, 157, -1,
1078 149, -1, 150, -1, 158, -1, 152, 152, -1, 153,
1079 153, -1, 146, 140, -1, 145, 140, -1, 147, 140,
1080 -1, 148, 140, -1, 157, 140, -1, 149, 140, -1,
1081 150, 140, -1, 158, 140, -1, 152, 152, 140, -1,
1082 153, 153, 140, -1, 151, -1, 137, 138, -1, 155,
1083 156, -1, 152, -1, 152, 140, -1, 140, 140, -1,
1084 144, 140, -1, 153, -1, 153, 140, -1, -1, 89,
1085 -1, -1, 111, -1, -1, 140, 93, -1, -1, 148,
1086 367, 148, -1, 368, -1, 367, 139, 368, -1, 30,
1087 -1, 30, 140, 369, -1, 254, -1, 30, 154, 255,
1088 145, 255, -1, 32, -1, 93, -1, -1, 43, 302,
1089 -1, -1, 44, 302, -1, -1, 45, 302, -1, -1,
1090 33, 302, -1, 375, -1, -1, 376, -1, 375, 139,
1091 376, -1, 390, 313, -1, -1, 63, 378, 380, -1,
1092 -1, 65, 379, 380, -1, 380, -1, -1, 90, 381,
1093 382, -1, 382, -1, 383, -1, 385, -1, -1, 83,
1094 384, 361, -1, 361, -1, 389, 30, 366, 386, 143,
1095 -1, -1, 141, 387, 142, -1, 388, -1, 387, 388,
1096 -1, 218, -1, 222, -1, 14, 302, -1, 15, 302,
1097 -1, 16, 302, -1, 89, 393, 392, 391, -1, 393,
1098 392, 391, -1, 389, 307, 366, -1, -1, 149, -1,
1099 -1, 392, 147, 89, -1, 392, 147, -1, 319, -1,
1100 319, 152, 394, 153, -1, 58, 319, -1, 86, 67,
1101 -1, 67, -1, 86, -1, 86, 68, -1, 68, -1,
1102 69, -1, 86, 69, -1, 69, 69, -1, 86, 69,
1103 69, -1, 70, -1, 71, -1, 66, -1, 85, 72,
1104 -1, 86, 72, -1, 72, -1, 73, -1, 74, -1,
1105 75, -1, 76, -1, 77, -1, 78, -1, 79, -1,
1106 80, -1, 81, -1, 82, -1, 91, -1, 92, -1,
1107 112, -1, 389, -1, 394, 139, 389, -1, -1, 106,
1108 137, 396, 138, -1, -1, 319, -1, 396, 139, 319,
1109 -1
1110 };
1111
1112 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1113 static const yytype_uint16 yyrline[] =
1114 {
1115 0, 546, 546, 547, 550, 550, 569, 570, 571, 572,
1116 573, 574, 575, 576, 577, 578, 579, 580, 581, 582,
1117 583, 584, 585, 586, 587, 588, 589, 590, 591, 592,
1118 593, 594, 595, 596, 597, 598, 599, 600, 603, 604,
1119 605, 606, 607, 608, 609, 610, 611, 612, 613, 614,
1120 627, 633, 638, 643, 644, 654, 661, 667, 672, 677,
1121 678, 688, 695, 704, 709, 714, 715, 725, 732, 743,
1122 748, 753, 754, 764, 771, 800, 805, 810, 811, 821,
1123 828, 856, 857, 868, 874, 882, 929, 933, 1040, 1045,
1124 1046, 1057, 1060, 1063, 1077, 1093, 1098, 1098, 1120, 1120,
1125 1186, 1200, 1201, 1204, 1205, 1206, 1210, 1214, 1223, 1232,
1126 1241, 1242, 1245, 1260, 1260, 1297, 1298, 1301, 1302, 1305,
1127 1305, 1334, 1335, 1338, 1344, 1350, 1355, 1360, 1361, 1371,
1128 1378, 1378, 1404, 1405, 1408, 1414, 1414, 1433, 1436, 1439,
1129 1442, 1447, 1448, 1453, 1461, 1477, 1485, 1491, 1496, 1497,
1130 1510, 1518, 1526, 1534, 1544, 1555, 1560, 1565, 1566, 1576,
1131 1583, 1594, 1599, 1604, 1605, 1615, 1622, 1634, 1639, 1644,
1132 1645, 1655, 1662, 1680, 1685, 1690, 1691, 1701, 1708, 1712,
1133 1717, 1718, 1728, 1731, 1734, 1748, 1761, 1761, 1771, 1776,
1134 1777, 1794, 1806, 1824, 1836, 1848, 1860, 1872, 1884, 1898,
1135 1902, 1907, 1908, 1918, 1921, 1924, 1927, 1941, 1942, 1958,
1136 1961, 1964, 1973, 1979, 1984, 1985, 1996, 2002, 2010, 2016,
1137 2021, 2026, 2027, 2037, 2044, 2050, 2056, 2062, 2067, 2072,
1138 2077, 2082, 2087, 2092, 2097, 2102, 2107, 2112, 2117, 2122,
1139 2128, 2133, 2139, 2145, 2151, 2157, 2163, 2169, 2175, 2180,
1140 2186, 2191, 2192, 2202, 2209, 2293, 2297, 2303, 2308, 2309,
1141 2320, 2326, 2334, 2337, 2340, 2349, 2355, 2360, 2361, 2372,
1142 2378, 2389, 2392, 2393, 2403, 2403, 2427, 2430, 2433, 2438,
1143 2441, 2446, 2447, 2450, 2451, 2454, 2455, 2456, 2500, 2501,
1144 2504, 2505, 2508, 2511, 2516, 2517, 2535, 2538, 2541, 2544,
1145 2547, 2550, 2555, 2558, 2561, 2564, 2567, 2570, 2573, 2578,
1146 2593, 2596, 2601, 2607, 2610, 2611, 2619, 2624, 2627, 2632,
1147 2641, 2651, 2654, 2658, 2662, 2666, 2670, 2674, 2680, 2685,
1148 2691, 2709, 2730, 2768, 2774, 2768, 2818, 2818, 2844, 2849,
1149 2855, 2849, 2895, 2896, 2899, 2900, 2903, 2955, 2958, 2961,
1150 2964, 2969, 2972, 2977, 2978, 2979, 2982, 2983, 2984, 2985,
1151 2986, 2987, 2988, 2989, 2990, 2991, 2992, 3003, 3007, 3011,
1152 3022, 3033, 3044, 3055, 3058, 3061, 3064, 3067, 3078, 3089,
1153 3100, 3111, 3112, 3113, 3114, 3125, 3136, 3147, 3154, 3161,
1154 3168, 3177, 3190, 3195, 3196, 3208, 3215, 3222, 3231, 3235,
1155 3240, 3241, 3251, 3254, 3257, 3271, 3272, 3275, 3278, 3284,
1156 3284, 3285, 3288, 3354, 3354, 3355, 3358, 3404, 3407, 3407,
1157 3418, 3421, 3421, 3433, 3451, 3471, 3515, 3593, 3594, 3595,
1158 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605,
1159 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3613, 3614, 3615,
1160 3616, 3617, 3618, 3619, 3620, 3621, 3624, 3627, 3632, 3635,
1161 3640, 3643, 3651, 3654, 3660, 3664, 3676, 3680, 3686, 3690,
1162 3713, 3717, 3723, 3726, 3731, 3734, 3739, 3742, 3747, 3750,
1163 3755, 3778, 3783, 3789, 3812, 3819, 3819, 3820, 3820, 3821,
1164 3825, 3825, 3826, 3830, 3831, 3835, 3835, 3836, 3839, 3863,
1165 3869, 3874, 3875, 3887, 3890, 3893, 3908, 3923, 3940, 3945,
1166 3959, 4067, 4070, 4078, 4081, 4084, 4089, 4097, 4108, 4123,
1167 4127, 4131, 4135, 4139, 4143, 4147, 4151, 4155, 4159, 4163,
1168 4167, 4171, 4175, 4179, 4183, 4187, 4191, 4195, 4199, 4203,
1169 4207, 4211, 4215, 4219, 4223, 4227, 4231, 4237, 4243, 4259,
1170 4262, 4270, 4276, 4283
1171 };
1172 #endif
1173
1174 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1175 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1176 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1177 static const char *const yytname[] =
1178 {
1179 "$end", "error", "$undefined", "TK_API", "TK_AUTOPYNAME",
1180 "TK_DEFDOCSTRFMT", "TK_DEFDOCSTRSIG", "TK_DEFENCODING", "TK_PLUGIN",
1181 "TK_VIRTERRORHANDLER", "TK_EXPTYPEHINTCODE", "TK_TYPEHINTCODE",
1182 "TK_DOCSTRING", "TK_EXTRACT", "TK_ACCESSCODE", "TK_GETCODE",
1183 "TK_SETCODE", "TK_PREINITCODE", "TK_INITCODE", "TK_POSTINITCODE",
1184 "TK_FINALCODE", "TK_UNITCODE", "TK_UNITPOSTINCLUDECODE", "TK_MODCODE",
1185 "TK_TYPECODE", "TK_COPYING", "TK_MAPPEDTYPE", "TK_CODELINE", "TK_IF",
1186 "TK_END", "TK_NAME_VALUE", "TK_PATH_VALUE", "TK_STRING_VALUE",
1187 "TK_VIRTUALCATCHERCODE", "TK_TRAVERSECODE", "TK_CLEARCODE",
1188 "TK_GETBUFFERCODE", "TK_RELEASEBUFFERCODE", "TK_READBUFFERCODE",
1189 "TK_WRITEBUFFERCODE", "TK_SEGCOUNTCODE", "TK_CHARBUFFERCODE",
1190 "TK_PICKLECODE", "TK_VIRTUALCALLCODE", "TK_METHODCODE",
1191 "TK_PREMETHODCODE", "TK_INSTANCECODE", "TK_FROMTYPE", "TK_TOTYPE",
1192 "TK_TOSUBCLASS", "TK_INCLUDE", "TK_IMPORT", "TK_EXPHEADERCODE",
1193 "TK_MODHEADERCODE", "TK_TYPEHEADERCODE", "TK_MODULE", "TK_COMPOMODULE",
1194 "TK_CLASS", "TK_STRUCT", "TK_PUBLIC", "TK_PROTECTED", "TK_PRIVATE",
1195 "TK_SIGNALS", "TK_SIGNAL_METHOD", "TK_SLOTS", "TK_SLOT_METHOD",
1196 "TK_BOOL", "TK_SHORT", "TK_INT", "TK_LONG", "TK_FLOAT", "TK_DOUBLE",
1197 "TK_CHAR", "TK_WCHAR_T", "TK_VOID", "TK_PYOBJECT", "TK_PYTUPLE",
1198 "TK_PYLIST", "TK_PYDICT", "TK_PYCALLABLE", "TK_PYSLICE", "TK_PYTYPE",
1199 "TK_PYBUFFER", "TK_VIRTUAL", "TK_ENUM", "TK_SIGNED", "TK_UNSIGNED",
1200 "TK_SCOPE", "TK_LOGICAL_OR", "TK_CONST", "TK_STATIC", "TK_PYSSIZET",
1201 "TK_SIZET", "TK_NUMBER_VALUE", "TK_REAL_VALUE", "TK_TYPEDEF",
1202 "TK_NAMESPACE", "TK_TIMELINE", "TK_PLATFORMS", "TK_FEATURE",
1203 "TK_LICENSE", "TK_QCHAR_VALUE", "TK_TRUE_VALUE", "TK_FALSE_VALUE",
1204 "TK_NULL_VALUE", "TK_OPERATOR", "TK_THROW", "TK_EXCEPTION",
1205 "TK_RAISECODE", "TK_EXPLICIT", "TK_TEMPLATE", "TK_FINAL", "TK_ELLIPSIS",
1206 "TK_DEFMETATYPE", "TK_DEFSUPERTYPE", "TK_PROPERTY", "TK_HIDE_NS",
1207 "TK_FORMAT", "TK_GET", "TK_ID", "TK_KWARGS", "TK_LANGUAGE",
1208 "TK_LICENSEE", "TK_NAME", "TK_OPTIONAL", "TK_ORDER", "TK_REMOVELEADING",
1209 "TK_SET", "TK_SIGNATURE", "TK_TIMESTAMP", "TK_TYPE", "TK_USEARGNAMES",
1210 "TK_USELIMITEDAPI", "TK_ALLRAISEPYEXC", "TK_CALLSUPERINIT",
1211 "TK_DEFERRORHANDLER", "TK_VERSION", "'('", "')'", "','", "'='", "'{'",
1212 "'}'", "';'", "'!'", "'-'", "'+'", "'*'", "'/'", "'&'", "'|'", "'~'",
1213 "'<'", "'>'", "':'", "'['", "']'", "'%'", "'^'", "$accept",
1214 "specification", "statement", "@1", "modstatement", "nsstatement",
1215 "defdocstringfmt", "defdocstringfmt_args", "defdocstringfmt_arg_list",
1216 "defdocstringfmt_arg", "defdocstringsig", "defdocstringsig_args",
1217 "defdocstringsig_arg_list", "defdocstringsig_arg", "defencoding",
1218 "defencoding_args", "defencoding_arg_list", "defencoding_arg", "plugin",
1219 "plugin_args", "plugin_arg_list", "plugin_arg", "virterrorhandler",
1220 "veh_args", "veh_arg_list", "veh_arg", "api", "api_arg_list", "api_arg",
1221 "exception", "baseexception", "exception_body",
1222 "exception_body_directives", "exception_body_directive", "raisecode",
1223 "mappedtype", "@2", "mappedtypetmpl", "@3", "mtdefinition", "mtbody",
1224 "mtline", "mtfunction", "namespace", "@4", "optnsbody", "nsbody",
1225 "platforms", "@5", "platformlist", "platform", "feature", "feature_args",
1226 "feature_arg_list", "feature_arg", "timeline", "@6", "qualifierlist",
1227 "qualifiername", "ifstart", "@7", "oredqualifiers", "qualifiers",
1228 "ifend", "license", "license_args", "license_arg_list", "license_arg",
1229 "defmetatype", "defmetatype_args", "defmetatype_arg_list",
1230 "defmetatype_arg", "defsupertype", "defsupertype_args",
1231 "defsupertype_arg_list", "defsupertype_arg", "hiddenns", "hiddenns_args",
1232 "hiddenns_arg_list", "hiddenns_arg", "compmodule", "compmodule_args",
1233 "compmodule_arg_list", "compmodule_arg", "compmodule_body",
1234 "compmodule_body_directives", "compmodule_body_directive", "module",
1235 "module_args", "@8", "module_arg_list", "module_arg", "module_body",
1236 "module_body_directives", "module_body_directive", "dottedname",
1237 "optnumber", "include", "include_args", "include_arg_list",
1238 "include_arg", "import", "import_args", "import_arg_list", "import_arg",
1239 "copying", "exphdrcode", "modhdrcode", "typehdrcode", "travcode",
1240 "clearcode", "getbufcode", "releasebufcode", "readbufcode",
1241 "writebufcode", "segcountcode", "charbufcode", "instancecode",
1242 "picklecode", "finalcode", "modcode", "typecode", "preinitcode",
1243 "initcode", "postinitcode", "unitcode", "unitpostinccode",
1244 "exptypehintcode", "modtypehintcode", "classtypehintcode", "autopyname",
1245 "autopyname_args", "autopyname_arg_list", "autopyname_arg", "docstring",
1246 "docstring_args", "docstring_arg_list", "docstring_arg", "optdocstring",
1247 "extract", "extract_args", "extract_arg_list", "extract_arg",
1248 "codeblock", "codelines", "enum", "@9", "optenumkey", "optname",
1249 "optenumbody", "enumbody", "enumline", "optcomma", "optenumassign",
1250 "optassign", "expr", "binop", "optunop", "value", "optcast",
1251 "scopedname", "scopednamehead", "scopepart", "bool_value", "simplevalue",
1252 "exprlist", "typedef", "struct", "@10", "@11", "classtmpl", "@12",
1253 "template", "class", "@13", "@14", "superclasses", "superlist",
1254 "superclass", "class_access", "optclassbody", "classbody", "classline",
1255 "property", "property_args", "property_arg_list", "property_arg",
1256 "property_body", "property_body_directives", "property_body_directive",
1257 "name_or_string", "optslot", "dtor", "@15", "dtor_decl", "ctor", "@16",
1258 "simplector", "optctorsig", "@17", "optsig", "@18", "function",
1259 "operatorname", "optconst", "optfinal", "optabstract", "optflags",
1260 "flaglist", "flag", "flagvalue", "virtualcallcode", "methodcode",
1261 "premethodcode", "virtualcatchercode", "arglist", "rawarglist",
1262 "argvalue", "varmember", "@19", "@20", "simple_varmem", "@21", "varmem",
1263 "member", "@22", "variable", "variable_body", "variable_body_directives",
1264 "variable_body_directive", "cpptype", "argtype", "optref", "deref",
1265 "basetype", "cpptypelist", "optexceptions", "exceptionlist", 0
1266 };
1267 #endif
1268
1269 # ifdef YYPRINT
1270 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1271 token YYLEX-NUM. */
1272 static const yytype_uint16 yytoknum[] =
1273 {
1274 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1275 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1276 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1277 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1278 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1279 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1280 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1281 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1282 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1283 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1284 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1285 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1286 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1287 385, 386, 387, 388, 389, 390, 391, 40, 41, 44,
1288 61, 123, 125, 59, 33, 45, 43, 42, 47, 38,
1289 124, 126, 60, 62, 58, 91, 93, 37, 94
1290 };
1291 # endif
1292
1293 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1294 static const yytype_uint16 yyr1[] =
1295 {
1296 0, 159, 160, 160, 162, 161, 163, 163, 163, 163,
1297 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
1298 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
1299 163, 163, 163, 163, 163, 163, 163, 163, 164, 164,
1300 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
1301 165, 166, 166, 167, 167, 168, 169, 170, 170, 171,
1302 171, 172, 173, 174, 174, 175, 175, 176, 177, 178,
1303 178, 179, 179, 180, 181, 182, 182, 183, 183, 184,
1304 185, 186, 186, 187, 187, 188, 189, 189, 190, 191,
1305 191, 192, 192, 192, 192, 193, 195, 194, 197, 196,
1306 198, 199, 199, 200, 200, 200, 200, 200, 200, 200,
1307 200, 200, 201, 203, 202, 204, 204, 205, 205, 207,
1308 206, 208, 208, 209, 210, 211, 211, 212, 212, 213,
1309 215, 214, 216, 216, 217, 219, 218, 220, 220, 220,
1310 220, 221, 221, 222, 223, 224, 224, 224, 225, 225,
1311 226, 226, 226, 226, 227, 228, 228, 229, 229, 230,
1312 231, 232, 232, 233, 233, 234, 235, 236, 236, 237,
1313 237, 238, 239, 240, 240, 241, 241, 242, 243, 243,
1314 244, 244, 245, 245, 245, 246, 248, 247, 247, 249,
1315 249, 250, 250, 250, 250, 250, 250, 250, 250, 251,
1316 251, 252, 252, 253, 253, 253, 253, 254, 254, 255,
1317 255, 256, 257, 257, 258, 258, 259, 259, 260, 261,
1318 261, 262, 262, 263, 264, 265, 266, 267, 268, 269,
1319 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
1320 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
1321 290, 291, 291, 292, 293, 294, 294, 294, 295, 295,
1322 296, 296, 297, 297, 298, 299, 299, 300, 300, 301,
1323 301, 302, 303, 303, 305, 304, 306, 306, 306, 307,
1324 307, 308, 308, 309, 309, 310, 310, 310, 311, 311,
1325 312, 312, 313, 313, 314, 314, 315, 315, 315, 315,
1326 315, 315, 316, 316, 316, 316, 316, 316, 316, 317,
1327 318, 318, 319, 319, 320, 320, 321, 322, 322, 323,
1328 323, 323, 323, 323, 323, 323, 323, 323, 324, 324,
1329 324, 325, 325, 327, 328, 326, 330, 329, 331, 333,
1330 334, 332, 335, 335, 336, 336, 337, 338, 338, 338,
1331 338, 339, 339, 340, 340, 340, 341, 341, 341, 341,
1332 341, 341, 341, 341, 341, 341, 341, 341, 341, 341,
1333 341, 341, 341, 341, 341, 341, 341, 341, 341, 341,
1334 341, 341, 341, 341, 341, 341, 341, 341, 341, 341,
1335 341, 342, 343, 344, 344, 345, 345, 345, 346, 346,
1336 347, 347, 348, 348, 348, 349, 349, 350, 350, 352,
1337 351, 351, 353, 355, 354, 354, 356, 357, 358, 357,
1338 359, 360, 359, 361, 361, 361, 361, 362, 362, 362,
1339 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
1340 362, 362, 362, 362, 362, 362, 362, 362, 362, 362,
1341 362, 362, 362, 362, 362, 362, 363, 363, 364, 364,
1342 365, 365, 366, 366, 367, 367, 368, 368, 369, 369,
1343 369, 369, 370, 370, 371, 371, 372, 372, 373, 373,
1344 374, 375, 375, 375, 376, 378, 377, 379, 377, 377,
1345 381, 380, 380, 382, 382, 384, 383, 383, 385, 386,
1346 386, 387, 387, 388, 388, 388, 388, 388, 389, 389,
1347 390, 391, 391, 392, 392, 392, 393, 393, 393, 393,
1348 393, 393, 393, 393, 393, 393, 393, 393, 393, 393,
1349 393, 393, 393, 393, 393, 393, 393, 393, 393, 393,
1350 393, 393, 393, 393, 393, 393, 393, 394, 394, 395,
1351 395, 396, 396, 396
1352 };
1353
1354 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1355 static const yytype_uint8 yyr2[] =
1356 {
1357 0, 2, 1, 2, 0, 2, 1, 1, 1, 1,
1358 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1359 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1360 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1361 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1362 2, 1, 3, 1, 3, 3, 2, 1, 3, 1,
1363 3, 3, 2, 1, 3, 1, 3, 3, 2, 1,
1364 3, 1, 3, 3, 3, 1, 3, 1, 3, 3,
1365 4, 1, 3, 3, 3, 5, 0, 3, 4, 1,
1366 2, 1, 1, 1, 1, 2, 0, 5, 0, 6,
1367 4, 1, 2, 1, 1, 1, 1, 2, 2, 1,
1368 1, 1, 14, 0, 5, 0, 3, 1, 2, 0,
1369 5, 1, 2, 1, 2, 1, 3, 1, 3, 3,
1370 0, 5, 1, 2, 1, 0, 5, 1, 2, 3,
1371 4, 1, 3, 1, 2, 0, 1, 3, 1, 3,
1372 3, 3, 3, 3, 2, 1, 3, 1, 3, 3,
1373 2, 1, 3, 1, 3, 3, 2, 1, 3, 1,
1374 3, 3, 3, 1, 3, 1, 3, 3, 0, 4,
1375 1, 2, 1, 1, 1, 3, 0, 2, 3, 1,
1376 3, 3, 3, 3, 3, 3, 3, 3, 3, 0,
1377 4, 1, 2, 1, 1, 1, 1, 1, 1, 0,
1378 1, 2, 1, 3, 1, 3, 3, 3, 2, 1,
1379 3, 1, 3, 3, 2, 2, 2, 2, 2, 2,
1380 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1381 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1382 3, 1, 3, 3, 3, 0, 1, 3, 1, 3,
1383 3, 3, 0, 1, 3, 1, 3, 1, 3, 3,
1384 3, 2, 1, 2, 0, 9, 0, 1, 1, 0,
1385 1, 0, 1, 1, 2, 1, 1, 4, 0, 1,
1386 0, 2, 0, 2, 1, 3, 1, 1, 1, 1,
1387 1, 1, 0, 1, 1, 1, 1, 1, 1, 3,
1388 0, 3, 2, 1, 1, 3, 1, 1, 1, 1,
1389 4, 2, 1, 1, 1, 1, 1, 1, 0, 1,
1390 3, 6, 12, 0, 0, 8, 0, 3, 4, 0,
1391 0, 8, 0, 2, 1, 3, 2, 0, 1, 1,
1392 1, 0, 3, 0, 1, 2, 1, 1, 1, 1,
1393 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1395 1, 1, 1, 1, 2, 2, 2, 3, 3, 3,
1396 2, 3, 3, 1, 3, 3, 3, 3, 0, 4,
1397 1, 2, 1, 1, 1, 1, 1, 0, 1, 0,
1398 3, 1, 11, 0, 3, 1, 11, 0, 0, 6,
1399 0, 0, 7, 17, 7, 17, 16, 1, 1, 1,
1400 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
1401 2, 2, 2, 2, 2, 3, 3, 1, 2, 2,
1402 1, 2, 2, 2, 1, 2, 0, 1, 0, 1,
1403 0, 2, 0, 3, 1, 3, 1, 3, 1, 5,
1404 1, 1, 0, 2, 0, 2, 0, 2, 0, 2,
1405 1, 0, 1, 3, 2, 0, 3, 0, 3, 1,
1406 0, 3, 1, 1, 1, 0, 3, 1, 5, 0,
1407 3, 1, 2, 1, 1, 2, 2, 2, 4, 3,
1408 3, 0, 1, 0, 3, 2, 1, 4, 2, 2,
1409 1, 1, 2, 1, 1, 2, 2, 3, 1, 1,
1410 1, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1411 1, 1, 1, 1, 1, 1, 1, 1, 3, 0,
1412 4, 0, 1, 3
1413 };
1414
1415 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1416 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1417 means the default is an error. */
1418 static const yytype_uint16 yydefact[] =
1419 {
1420 4, 4, 2, 0, 1, 3, 0, 0, 0, 0,
1421 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1422 0, 0, 0, 0, 143, 316, 0, 0, 0, 0,
1423 0, 0, 0, 0, 0, 530, 520, 523, 524, 528,
1424 529, 533, 534, 535, 536, 537, 538, 539, 540, 541,
1425 542, 543, 276, 0, 521, 0, 0, 544, 545, 0,
1426 0, 130, 119, 0, 145, 0, 0, 0, 546, 0,
1427 0, 0, 5, 37, 10, 11, 12, 6, 35, 7,
1428 44, 24, 36, 40, 28, 18, 31, 38, 39, 23,
1429 13, 14, 19, 8, 25, 21, 20, 9, 15, 27,
1430 49, 26, 29, 22, 30, 33, 34, 16, 32, 17,
1431 46, 516, 313, 314, 45, 41, 43, 336, 42, 47,
1432 48, 0, 513, 0, 51, 0, 50, 57, 0, 56,
1433 63, 0, 62, 69, 0, 68, 75, 0, 0, 272,
1434 246, 0, 247, 265, 0, 0, 241, 242, 243, 244,
1435 245, 239, 224, 0, 462, 135, 212, 0, 211, 219,
1436 0, 218, 225, 226, 227, 207, 208, 0, 199, 186,
1437 0, 178, 173, 339, 333, 526, 277, 278, 279, 531,
1438 519, 522, 525, 532, 312, 513, 0, 113, 0, 0,
1439 125, 0, 124, 146, 0, 144, 0, 86, 0, 0,
1440 154, 155, 0, 160, 161, 0, 166, 167, 0, 0,
1441 0, 0, 462, 0, 511, 0, 0, 0, 81, 0,
1442 0, 53, 0, 0, 59, 0, 0, 65, 0, 0,
1443 71, 0, 0, 77, 74, 273, 271, 0, 0, 0,
1444 267, 264, 518, 0, 96, 279, 0, 0, 0, 214,
1445 0, 0, 221, 0, 0, 0, 0, 0, 0, 0,
1446 0, 0, 189, 0, 185, 187, 0, 0, 175, 0,
1447 172, 342, 342, 280, 462, 527, 511, 462, 0, 115,
1448 0, 0, 0, 0, 127, 0, 0, 0, 0, 0,
1449 148, 481, 0, 462, 547, 0, 0, 0, 157, 0,
1450 0, 163, 0, 0, 169, 0, 315, 462, 337, 481,
1451 499, 0, 0, 0, 428, 427, 429, 430, 432, 433,
1452 447, 450, 454, 0, 431, 434, 0, 515, 512, 509,
1453 0, 0, 80, 0, 0, 52, 0, 0, 58, 0,
1454 0, 64, 0, 0, 70, 0, 0, 76, 0, 0,
1455 0, 266, 0, 466, 0, 464, 0, 137, 0, 141,
1456 0, 0, 0, 0, 213, 0, 0, 220, 0, 0,
1457 0, 0, 0, 0, 0, 0, 0, 188, 0, 0,
1458 255, 203, 204, 0, 201, 205, 206, 0, 174, 0,
1459 182, 183, 0, 180, 184, 347, 462, 462, 274, 508,
1460 0, 0, 0, 0, 134, 0, 132, 123, 0, 121,
1461 0, 126, 0, 0, 0, 0, 0, 147, 0, 0,
1462 480, 482, 279, 292, 0, 0, 0, 338, 0, 156,
1463 0, 0, 162, 0, 0, 168, 0, 517, 98, 0,
1464 0, 0, 448, 0, 452, 453, 438, 437, 439, 440,
1465 442, 443, 451, 435, 455, 436, 449, 441, 444, 481,
1466 514, 405, 406, 83, 84, 82, 55, 54, 61, 60,
1467 67, 66, 73, 72, 79, 78, 269, 270, 268, 0,
1468 0, 463, 0, 97, 138, 0, 136, 279, 216, 317,
1469 318, 217, 215, 223, 222, 191, 192, 193, 194, 195,
1470 196, 197, 198, 190, 0, 249, 256, 0, 0, 0,
1471 202, 177, 176, 0, 181, 348, 349, 350, 343, 344,
1472 0, 340, 334, 0, 262, 0, 117, 0, 336, 114,
1473 131, 133, 120, 122, 129, 128, 151, 152, 153, 150,
1474 149, 456, 0, 462, 310, 484, 87, 0, 85, 548,
1475 159, 158, 165, 164, 171, 170, 0, 456, 0, 0,
1476 0, 503, 504, 0, 501, 498, 0, 445, 446, 0,
1477 207, 470, 471, 468, 467, 465, 0, 0, 0, 0,
1478 0, 0, 101, 111, 103, 104, 105, 109, 106, 110,
1479 139, 0, 142, 0, 0, 251, 0, 0, 0, 258,
1480 254, 200, 179, 347, 346, 351, 351, 281, 263, 331,
1481 0, 116, 118, 457, 458, 483, 510, 0, 293, 294,
1482 302, 0, 0, 89, 93, 91, 92, 94, 99, 458,
1483 505, 506, 507, 500, 502, 0, 456, 209, 240, 236,
1484 107, 108, 0, 0, 102, 140, 0, 250, 0, 0,
1485 0, 257, 0, 345, 353, 0, 0, 290, 285, 286,
1486 0, 282, 283, 0, 459, 549, 0, 296, 297, 298,
1487 299, 300, 301, 310, 303, 305, 306, 307, 308, 304,
1488 0, 95, 0, 90, 549, 424, 458, 210, 0, 0,
1489 100, 253, 252, 260, 261, 259, 0, 0, 316, 0,
1490 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1491 0, 407, 407, 407, 0, 485, 487, 495, 490, 413,
1492 0, 0, 362, 358, 356, 357, 368, 369, 370, 371,
1493 372, 373, 374, 375, 376, 377, 378, 379, 367, 380,
1494 366, 364, 363, 359, 361, 360, 0, 354, 365, 382,
1495 411, 381, 415, 497, 383, 489, 492, 493, 494, 341,
1496 335, 310, 462, 0, 284, 0, 0, 460, 311, 295,
1497 326, 323, 322, 327, 325, 0, 319, 324, 309, 0,
1498 88, 460, 549, 209, 481, 248, 238, 481, 228, 229,
1499 230, 231, 232, 233, 234, 235, 237, 386, 385, 384,
1500 408, 0, 0, 0, 390, 0, 0, 0, 0, 0,
1501 0, 0, 398, 0, 352, 355, 291, 288, 275, 462,
1502 551, 0, 462, 321, 310, 462, 460, 469, 0, 0,
1503 387, 388, 389, 495, 486, 488, 410, 496, 0, 491,
1504 0, 414, 0, 0, 0, 0, 393, 0, 391, 0,
1505 289, 287, 0, 552, 0, 461, 420, 329, 0, 420,
1506 462, 456, 549, 0, 0, 0, 0, 392, 0, 402,
1507 403, 404, 0, 400, 549, 262, 550, 0, 421, 0,
1508 320, 310, 0, 420, 549, 462, 395, 396, 397, 394,
1509 0, 401, 460, 332, 553, 0, 476, 330, 262, 0,
1510 462, 417, 399, 462, 0, 0, 474, 476, 476, 420,
1511 418, 0, 0, 481, 477, 0, 478, 474, 474, 0,
1512 0, 262, 476, 0, 475, 0, 472, 478, 478, 262,
1513 481, 476, 474, 0, 479, 0, 426, 472, 472, 476,
1514 0, 474, 478, 422, 473, 423, 425, 474, 0, 416,
1515 412, 112, 419
1516 };
1517
1518 /* YYDEFGOTO[NTERM-NUM]. */
1519 static const yytype_int16 yydefgoto[] =
1520 {
1521 -1, 1, 2, 3, 72, 73, 74, 126, 220, 221,
1522 75, 129, 223, 224, 76, 132, 226, 227, 77, 135,
1523 229, 230, 78, 138, 232, 233, 79, 217, 218, 80,
1524 293, 548, 622, 623, 624, 81, 356, 82, 556, 483,
1525 581, 582, 583, 83, 279, 403, 527, 84, 189, 408,
1526 409, 85, 192, 283, 284, 86, 188, 405, 406, 87,
1527 245, 359, 360, 88, 89, 195, 289, 290, 90, 200,
1528 297, 298, 91, 203, 300, 301, 92, 206, 303, 304,
1529 93, 171, 267, 268, 270, 392, 393, 94, 168, 265,
1530 261, 262, 264, 383, 384, 169, 688, 95, 158, 248,
1531 249, 96, 161, 251, 252, 97, 98, 99, 100, 727,
1532 728, 729, 730, 731, 732, 733, 734, 587, 736, 737,
1533 101, 588, 102, 103, 104, 105, 106, 107, 108, 739,
1534 385, 505, 594, 595, 608, 508, 598, 599, 609, 109,
1535 145, 239, 240, 140, 141, 110, 523, 178, 274, 660,
1536 661, 662, 851, 762, 545, 618, 673, 680, 619, 620,
1537 111, 112, 113, 491, 778, 858, 114, 115, 272, 606,
1538 116, 211, 528, 118, 271, 605, 396, 518, 519, 520,
1539 655, 746, 747, 748, 812, 845, 846, 848, 872, 873,
1540 463, 801, 749, 807, 750, 751, 810, 752, 911, 920,
1541 879, 895, 753, 326, 614, 665, 822, 244, 354, 355,
1542 574, 936, 916, 906, 926, 419, 420, 421, 754, 805,
1543 806, 755, 809, 756, 757, 808, 758, 441, 563, 564,
1544 121, 423, 329, 214, 122, 295, 767, 854
1545 };
1546
1547 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1548 STATE-NUM. */
1549 #define YYPACT_NINF -771
1550 static const yytype_int16 yypact[] =
1551 {
1552 -771, 171, -771, 1099, -771, -771, 43, 62, 71, 72,
1553 41, 46, 161, 161, 48, 161, 161, 161, 161, 161,
1554 161, 161, 1263, 63, -771, -771, 14, 50, 161, 161,
1555 161, 52, 54, 125, 125, -771, -771, -771, 160, -771,
1556 -771, -771, -771, -771, -771, -771, -771, -771, -771, -771,
1557 -771, -771, 310, 165, 288, 225, 1263, -771, -771, 1210,
1558 232, -771, -771, 57, 74, 1210, 125, 124, -771, 61,
1559 65, 33, -771, -771, -771, -771, -771, -771, -771, -771,
1560 -771, -771, -771, -771, -771, -771, -771, -771, -771, -771,
1561 -771, -771, -771, -771, -771, -771, -771, -771, -771, -771,
1562 -771, -771, -771, -771, -771, -771, -771, -771, -771, -771,
1563 -771, 181, 251, -771, -771, -771, -771, 316, -771, -771,
1564 -771, 60, -771, 108, -771, 230, -771, -771, 242, -771,
1565 -771, 247, -771, -771, 252, -771, -771, 260, 161, -771,
1566 -771, 92, -771, -771, 67, 161, -771, -771, -771, -771,
1567 -771, -771, -771, 125, 231, -771, -771, 258, -771, -771,
1568 262, -771, -771, -771, -771, -771, -771, 157, 274, -771,
1569 275, 276, -771, -771, 26, -771, -771, -771, 343, -771,
1570 -771, -771, 355, -771, 251, -771, 70, -771, 289, 312,
1571 -771, 345, -771, -771, 153, -771, 336, 346, 1210, 371,
1572 -771, -771, 383, -771, -771, 384, -771, -771, 1210, 225,
1573 1263, 452, 88, 495, 118, 272, 372, 250, -771, 373,
1574 253, -771, 374, 255, -771, 375, 263, -771, 376, 265,
1575 -771, 377, 267, -771, -771, -771, -771, 378, 379, 269,
1576 -771, -771, -771, 490, -771, 2, 381, 382, 271, -771,
1577 386, 283, -771, 387, 388, 389, 390, 391, 392, 393,
1578 395, 290, -771, 210, -771, -771, 396, 294, -771, 105,
1579 -771, 370, 370, -771, 231, -771, 118, 231, 397, 398,
1580 493, 507, 400, 324, -771, 402, 403, 410, 411, 326,
1581 -771, 1210, 125, 231, -771, -27, 412, 328, -771, 413,
1582 331, -771, 414, 333, -771, 5, -771, 231, -771, 1210,
1583 415, 417, 116, 418, 419, 420, 421, 427, 428, 430,
1584 -771, -3, 101, 401, 431, 432, 436, 449, -771, -771,
1585 334, 481, -771, 108, 543, -771, 230, 544, -771, 242,
1586 563, -771, 247, 569, -771, 252, 571, -771, 260, 574,
1587 512, -771, 67, 466, 87, -771, 469, 462, 584, 527,
1588 480, 475, 590, 293, -771, 258, 593, -771, 262, 594,
1589 595, 447, 293, 293, 293, 293, 598, -771, 157, 492,
1590 76, -771, -771, 37, -771, -771, -771, 447, -771, 275,
1591 -771, -771, 18, -771, -771, 257, 231, 231, -771, -771,
1592 488, 603, 741, 506, -771, 34, -771, -771, 40, -771,
1593 334, -771, 345, 606, 619, 622, 623, -771, 153, 518,
1594 519, -771, 343, 521, 524, 522, 1210, -771, 447, -771,
1595 371, 447, -771, 383, 125, -771, 384, -771, -771, 526,
1596 256, 516, -771, 1210, -771, -771, -771, -771, -771, -771,
1597 -771, -771, -771, 525, -771, 528, -771, -771, -771, 1210,
1598 -771, -771, -771, -771, -771, -771, -771, -771, -771, -771,
1599 -771, -771, -771, -771, -771, -771, -771, -771, -771, 84,
1600 490, -771, 330, -771, -771, 20, -771, 343, -771, -771,
1601 -771, -771, -771, -771, -771, -771, -771, -771, -771, -771,
1602 -771, -771, -771, -771, 540, -771, -771, 25, 161, 532,
1603 -771, -771, -771, 534, -771, -771, -771, -771, 530, -771,
1604 125, -771, -771, 529, 655, 533, -771, 644, -771, -771,
1605 -771, -771, -771, -771, -771, -771, -771, -771, -771, -771,
1606 -771, 589, 1210, 231, 542, -771, -771, 82, -771, -771,
1607 -771, -771, -771, -771, -771, -771, 469, 589, 161, 161,
1608 161, -771, -771, 39, -771, -771, 561, -771, -771, 566,
1609 551, -771, -771, -771, -771, -771, 161, 161, 161, 161,
1610 1210, 51, -771, -771, -771, -771, -771, -771, -771, -771,
1611 -771, 650, -771, 541, 341, -771, 567, 568, 347, -771,
1612 -771, -771, -771, 257, -771, 565, 565, 295, -771, -771,
1613 545, -771, -771, -771, 616, -771, -771, 125, 202, -771,
1614 190, 161, 32, -771, -771, -771, -771, -771, -771, 616,
1615 -771, -771, -771, -771, -771, 591, 589, 639, -771, -771,
1616 -771, -771, 679, 599, -771, -771, 705, -771, 540, 711,
1617 712, -771, 25, -771, 988, 602, 604, 608, -771, -771,
1618 610, 295, -771, 1210, -771, 640, 612, -771, -771, -771,
1619 -771, -771, -771, 542, -771, -771, -771, -771, -771, -771,
1620 228, -771, 614, -771, 640, -771, 616, -771, 613, 618,
1621 -771, -771, -771, -771, -771, -771, 161, 161, 624, 161,
1622 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
1623 161, 689, 689, 689, 605, -771, -771, 609, -771, -771,
1624 626, 734, -771, -771, -771, -771, -771, -771, -771, -771,
1625 -771, -771, -771, -771, -771, -771, -771, -771, -771, -771,
1626 -771, -771, -771, -771, -771, -771, 869, -771, -771, -771,
1627 -771, -771, -771, -771, -771, -771, -771, -771, -771, -771,
1628 -771, 542, 231, 625, -771, 350, 628, 627, -771, -771,
1629 -771, -771, -771, -771, -771, 630, 80, -771, -771, 629,
1630 -771, 627, 640, 639, 1210, -771, -771, 1210, -771, -771,
1631 -771, -771, -771, -771, -771, -771, -771, -771, -771, -771,
1632 -771, 620, 621, 631, -771, 369, 369, 632, 511, 1152,
1633 743, 134, 635, 641, -771, -771, -771, 638, -771, 231,
1634 125, 686, 231, -771, 224, 231, 627, -771, 642, 643,
1635 -771, -771, -771, -771, -771, -771, -771, -771, 79, -771,
1636 624, -771, 647, 648, 649, 352, -771, 105, -771, 646,
1637 -771, -771, 651, -771, 354, -771, 636, 202, 360, 636,
1638 231, 589, 640, 645, 760, 334, 762, -771, 134, -771,
1639 -771, -771, 30, -771, 640, 655, -771, 125, -771, 653,
1640 -771, 542, 657, 636, 640, 231, -771, -771, -771, -771,
1641 658, -771, 627, -771, -771, 1210, 748, 202, 655, 659,
1642 231, 669, -771, 231, 666, 161, 761, 748, 748, 636,
1643 -771, 661, 688, 1210, -771, 161, 796, 761, 761, 691,
1644 698, 655, 748, 700, -771, 161, 797, 796, 796, 655,
1645 1210, 748, 761, 683, -771, 161, -771, 797, 797, 748,
1646 703, 761, 796, -771, -771, -771, -771, 761, 687, -771,
1647 -771, -771, -771
1648 };
1649
1650 /* YYPGOTO[NTERM-NUM]. */
1651 static const yytype_int16 yypgoto[] =
1652 {
1653 -771, -771, 841, -771, -771, -358, -771, -771, -771, 508,
1654 -771, -771, -771, 513, -771, -771, -771, 503, -771, -771,
1655 -771, 502, -771, -771, -771, 509, -771, -771, 517, -603,
1656 -771, -771, -771, 233, -771, -771, -771, -771, -771, 300,
1657 -771, 277, -771, -585, -771, -771, -771, -771, -771, -771,
1658 451, -771, -771, -771, 448, -771, -771, -771, 456, -236,
1659 -771, -771, -771, -235, -771, -771, -771, 444, -771, -771,
1660 -771, 433, -771, -771, -771, 435, -771, -771, -771, 429,
1661 -771, -771, -771, 477, -771, -771, 472, -771, -771, -771,
1662 -771, 491, -771, -771, 487, 3, 89, -771, -771, -771,
1663 510, -771, -771, -771, 505, -771, -771, -771, -459, -771,
1664 -771, -771, -771, -771, -771, -771, -771, -536, -771, -771,
1665 -771, -531, -771, -771, -771, -771, -771, -771, -771, -771,
1666 -771, -771, -771, 223, -238, -771, -771, 222, -655, -771,
1667 -771, -771, 531, -13, -771, -453, -771, -771, -219, -771,
1668 -771, 215, -771, -771, -771, -658, -771, -771, -611, -771,
1669 -23, 822, 670, -336, -771, -771, -530, -527, -771, -771,
1670 -525, -771, 875, -197, -771, -771, 615, -771, 279, -771,
1671 280, -771, 139, -771, -771, -771, 22, -771, -771, 16,
1672 -390, -212, -771, -771, 93, -771, -771, 81, -771, -771,
1673 -770, -771, -2, -771, -535, -462, -724, -200, -771, 416,
1674 -771, -435, -668, -680, -694, -300, -771, 353, -771, -771,
1675 -771, -301, -771, 85, -771, -771, 21, -771, -771, 338,
1676 -46, -771, 637, 729, -4, -187, -644, -771
1677 };
1678
1679 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1680 positive, shift that token. If negative, reduce the rule which
1681 number is the opposite. If zero, do what YYDEFACT says.
1682 If YYTABLE_NINF, syntax error. */
1683 #define YYTABLE_NINF -519
1684 static const yytype_int16 yytable[] =
1685 {
1686 142, 119, 146, 147, 148, 149, 150, 151, 152, 439,
1687 173, 174, 310, 186, 308, 162, 163, 164, 154, 196,
1688 534, 305, 629, 586, 120, 386, 361, 381, 382, 589,
1689 380, 394, 357, 390, 391, 172, 498, 499, 500, 501,
1690 781, 379, 380, 197, 526, 156, 23, 24, 207, 380,
1691 590, 722, 185, 558, 559, 560, -518, 825, 23, 24,
1692 23, 24, 769, 25, 404, 23, 24, 23, 24, 723,
1693 407, 133, 201, 204, 398, 576, 136, 400, 143, 23,
1694 24, 159, 165, 166, 165, 166, 30, 190, 627, 882,
1695 212, 165, 166, 425, 124, 165, 166, 577, 578, 579,
1696 277, 686, 860, 127, 130, 30, 193, 438, 506, 863,
1697 23, 24, 426, 899, 570, 166, 571, 380, 735, 235,
1698 55, 236, 586, 738, 742, 234, 427, 743, 589, 744,
1699 242, -518, 241, 23, 24, 52, 30, 452, 826, 919,
1700 621, 580, 596, 722, 426, 386, 358, 381, 382, 453,
1701 816, 157, 294, 597, 394, 25, 390, 391, 437, 569,
1702 513, 723, 294, 627, 591, 213, 857, 684, 903, 612,
1703 205, 4, 890, -518, 682, -518, 530, 572, 134, 509,
1704 123, 633, 532, 137, 213, 144, 237, 160, 139, 167,
1705 621, 170, 238, 643, 191, 726, 521, 522, 199, 125,
1706 155, 741, 202, 543, 561, 562, 307, 278, 128, 131,
1707 735, 194, 55, 507, 379, 738, 742, -516, 885, 743,
1708 893, 744, 380, 897, 782, 309, 480, 917, 918, 175,
1709 892, 215, 208, 937, 938, 481, 243, 179, 23, 24,
1710 900, 454, 932, 907, 216, 422, 584, 585, 950, 927,
1711 928, 941, 842, 443, 455, 25, 444, 843, 25, 947,
1712 770, 844, 187, 422, 942, 327, 931, 328, 592, 424,
1713 558, 559, 560, 949, 939, 285, 198, 253, 254, 951,
1714 255, 286, 287, 288, 23, 24, 153, 726, 256, 257,
1715 258, 259, 260, 741, 35, 36, 37, 38, 39, 40,
1716 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
1717 51, 625, 626, 53, 54, 55, 515, 516, 517, 57,
1718 58, 771, 772, 23, 24, 657, 884, 561, 562, 773,
1719 489, 490, 774, 208, 674, 675, 676, 677, 209, 678,
1720 68, 679, 210, 616, 777, 584, 585, 667, 668, 669,
1721 670, 671, 672, 219, 576, 180, 181, 182, 23, 24,
1722 183, 617, -328, -328, 461, 222, 462, 176, 177, 775,
1723 225, 658, 659, 273, 497, 228, 577, 578, 579, 243,
1724 549, 246, 247, 231, 30, 250, 625, 626, 332, 333,
1725 511, 335, 336, 338, 339, 489, 490, 566, 266, 25,
1726 119, 341, 342, 344, 345, 347, 348, 351, 352, 364,
1727 365, 554, 330, 422, 52, 263, 740, 269, 724, 725,
1728 580, 367, 368, 120, 275, 658, 659, 153, 377, 378,
1729 280, 550, 388, 389, 552, 35, 36, 37, 38, 39,
1730 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
1731 50, 51, 833, 281, 53, 54, 55, 745, 56, 718,
1732 57, 58, 411, 412, 417, 418, 429, 430, 282, 432,
1733 433, 435, 436, 291, 65, 887, 765, 165, 166, 647,
1734 648, 68, 573, 292, 828, 651, 652, 829, 819, 426,
1735 867, 868, 876, 877, 296, 600, 422, 604, 880, 881,
1736 802, 803, 945, 946, 834, 835, 299, 302, 740, 33,
1737 724, 725, 331, 334, 337, 340, 343, 346, 349, 350,
1738 353, 362, 363, 404, 395, 119, 366, 369, 370, 371,
1739 372, 373, 374, 375, 642, 376, 387, 407, 460, 402,
1740 410, 25, 413, 414, 401, 630, 631, 632, 120, 745,
1741 415, 416, 428, 431, 434, 442, 440, 456, 445, 446,
1742 447, 448, 817, 638, 639, 640, 641, 449, 450, 153,
1743 451, 457, 458, 459, 464, 466, 468, 35, 36, 37,
1744 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
1745 48, 49, 50, 51, 666, 470, 53, 54, 55, 472,
1746 56, 474, 57, 58, 476, 477, 479, -280, 681, 871,
1747 482, 869, 870, 923, 484, 485, 65, 294, 486, 852,
1748 487, 488, 856, 68, 493, 859, 495, 496, 502, 504,
1749 940, 524, 311, 525, 871, 312, 869, 870, 536, 313,
1750 314, 315, 316, 317, 318, 319, 320, 321, 322, 529,
1751 323, 537, 324, 325, 538, 539, 541, 776, 542, 565,
1752 883, 544, 546, 547, 557, 567, 593, 380, 568, 603,
1753 607, 610, 23, 24, 25, 601, 779, 602, 613, 617,
1754 645, 646, 663, 785, 786, 901, 788, 789, 790, 791,
1755 792, 793, 794, 795, 796, 797, 798, 799, 30, 635,
1756 909, 33, 34, 912, 636, 637, 654, 649, 650, 689,
1757 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1758 45, 46, 47, 48, 49, 50, 51, 664, 52, 53,
1759 54, 55, 687, 56, 685, 57, 58, 691, 422, 59,
1760 60, 422, 690, 693, 694, 759, 766, 760, 761, 65,
1761 768, 66, 763, 800, 67, 784, 68, 780, 783, 804,
1762 -409, 787, 838, 811, 813, 820, 824, 821, 818, 23,
1763 24, 25, 823, 840, 830, 831, 847, 850, 849, 855,
1764 861, 862, 309, 721, 874, 832, 611, 864, 865, 866,
1765 886, 878, 888, 905, 875, 30, 896, 853, 33, 34,
1766 898, 902, 908, 913, 921, 915, 837, 35, 36, 37,
1767 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
1768 48, 49, 50, 51, 910, 52, 53, 54, 55, 925,
1769 56, 922, 57, 58, 929, 930, 59, 60, 933, 943,
1770 935, 948, 5, 952, 467, 471, 65, 473, 66, 904,
1771 465, 67, 469, 68, 894, 683, 628, 475, 644, 533,
1772 535, 531, 540, 551, 514, 555, 512, 422, 553, 503,
1773 510, 692, 827, 494, 695, 492, 764, 184, 117, 306,
1774 696, 380, 653, 478, 422, 815, 656, 397, 891, 697,
1775 889, 841, 914, 576, 839, 615, 575, 23, 24, 698,
1776 836, 634, 924, 699, 700, 701, 702, 703, 704, 705,
1777 706, 707, 934, 399, 276, 577, 708, 709, 710, 0,
1778 0, 0, 944, 30, 0, 0, 33, 34, 711, 712,
1779 713, 714, 715, 0, 716, 35, 36, 37, 38, 39,
1780 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
1781 50, 51, 717, 52, 53, 54, 55, 0, 56, 718,
1782 57, 58, 0, 0, 59, 60, 0, 0, 0, 0,
1783 0, 0, 0, 0, 65, 0, 66, 0, 719, 67,
1784 0, 68, 0, 0, 720, 0, 0, 0, 0, 0,
1785 0, 0, 0, 0, 0, 0, 0, 0, 0, 696,
1786 380, 0, 0, 0, 0, 0, 0, 0, 697, 0,
1787 0, 814, 576, 0, 0, 0, 23, 24, 698, 0,
1788 721, 0, 699, 700, 701, 702, 703, 704, 705, 706,
1789 707, 0, 0, 0, 577, 708, 709, 710, 0, 0,
1790 0, 0, 30, 0, 0, 33, 34, 711, 712, 713,
1791 714, 715, 0, 716, 35, 36, 37, 38, 39, 40,
1792 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
1793 51, 717, 52, 53, 54, 55, 0, 56, 718, 57,
1794 58, 0, 0, 59, 60, 0, 0, 0, 0, 0,
1795 0, 0, 0, 65, 0, 66, 0, 719, 67, 0,
1796 68, 0, 6, 720, 7, 8, 9, 10, 11, 12,
1797 13, 0, 14, 0, 0, 0, 15, 16, 17, 0,
1798 18, 19, 20, 0, 21, 22, 0, 23, 24, 25,
1799 0, 0, 0, 0, 0, 0, 0, 0, 0, 721,
1800 0, 0, 0, 0, 0, 0, 0, 0, 0, 26,
1801 27, 28, 29, 30, 31, 32, 33, 34, 0, 0,
1802 0, 0, 0, 0, 0, 35, 36, 37, 38, 39,
1803 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
1804 50, 51, 25, 52, 53, 54, 55, 0, 56, 0,
1805 57, 58, 0, 0, 59, 60, 61, 62, 63, 64,
1806 0, 0, 0, 0, 65, 0, 66, 0, 0, 67,
1807 153, 68, 69, 70, 0, 71, 0, 0, 35, 36,
1808 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1809 47, 48, 49, 50, 51, 833, 0, 53, 54, 55,
1810 25, 56, 0, 57, 58, 0, 0, 0, 0, 0,
1811 0, 0, 0, 0, 0, 0, 0, 65, 0, 0,
1812 0, 0, 0, 0, 68, 0, 0, 0, 153, 0,
1813 0, 0, 0, 0, 0, 0, 35, 36, 37, 38,
1814 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
1815 49, 50, 51, 25, 0, 53, 54, 55, 0, 56,
1816 0, 57, 58, 0, 0, 0, 0, 0, 0, 0,
1817 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1818 0, 153, 68, 0, 0, 0, 0, 0, 0, 35,
1819 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
1820 46, 47, 48, 49, 50, 51, 0, 0, 53, 54,
1821 55, 0, 0, 0, 57, 58, 0, 0, 0, 0,
1822 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1823 0, 0, 0, 0, 0, 68
1824 };
1825
1826 static const yytype_int16 yycheck[] =
1827 {
1828 13, 3, 15, 16, 17, 18, 19, 20, 21, 309,
1829 33, 34, 212, 59, 211, 28, 29, 30, 22, 65,
1830 410, 208, 557, 482, 3, 263, 245, 263, 263, 482,
1831 12, 269, 30, 269, 269, 32, 372, 373, 374, 375,
1832 684, 4, 12, 66, 402, 31, 28, 29, 71, 12,
1833 30, 654, 56, 14, 15, 16, 30, 781, 28, 29,
1834 28, 29, 673, 30, 30, 28, 29, 28, 29, 654,
1835 30, 30, 69, 70, 274, 24, 30, 277, 30, 28,
1836 29, 31, 30, 31, 30, 31, 54, 30, 547, 859,
1837 30, 30, 31, 293, 32, 30, 31, 46, 47, 48,
1838 30, 636, 826, 32, 32, 54, 32, 307, 32, 30,
1839 28, 29, 139, 883, 30, 31, 32, 12, 654, 27,
1840 87, 29, 581, 654, 654, 138, 153, 654, 581, 654,
1841 153, 105, 145, 28, 29, 84, 54, 140, 782, 909,
1842 108, 90, 117, 746, 139, 383, 144, 383, 383, 152,
1843 761, 137, 198, 128, 392, 30, 392, 392, 153, 459,
1844 142, 746, 208, 622, 144, 105, 824, 629, 892, 527,
1845 137, 0, 142, 147, 142, 149, 142, 93, 137, 142,
1846 137, 142, 142, 137, 105, 137, 119, 137, 27, 137,
1847 108, 137, 125, 142, 137, 654, 396, 397, 137, 137,
1848 137, 654, 137, 422, 440, 440, 210, 137, 137, 137,
1849 746, 137, 87, 137, 4, 746, 746, 137, 862, 746,
1850 875, 746, 12, 881, 686, 137, 139, 907, 908, 69,
1851 874, 123, 152, 927, 928, 148, 148, 72, 28, 29,
1852 884, 140, 922, 898, 136, 291, 482, 482, 942, 917,
1853 918, 931, 118, 137, 153, 30, 140, 123, 30, 939,
1854 32, 127, 30, 309, 932, 147, 921, 149, 487, 292,
1855 14, 15, 16, 941, 929, 122, 152, 120, 121, 947,
1856 123, 128, 129, 130, 28, 29, 58, 746, 131, 132,
1857 133, 134, 135, 746, 66, 67, 68, 69, 70, 71,
1858 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1859 82, 547, 547, 85, 86, 87, 59, 60, 61, 91,
1860 92, 93, 94, 28, 29, 30, 861, 563, 563, 101,
1861 102, 103, 104, 152, 144, 145, 146, 147, 87, 149,
1862 112, 151, 26, 543, 680, 581, 581, 145, 146, 147,
1863 148, 149, 150, 123, 24, 67, 68, 69, 28, 29,
1864 72, 137, 138, 139, 30, 123, 32, 57, 58, 141,
1865 123, 607, 607, 30, 371, 123, 46, 47, 48, 148,
1866 426, 123, 124, 123, 54, 123, 622, 622, 138, 139,
1867 387, 138, 139, 138, 139, 102, 103, 443, 123, 30,
1868 402, 138, 139, 138, 139, 138, 139, 138, 139, 138,
1869 139, 434, 140, 459, 84, 141, 654, 141, 654, 654,
1870 90, 138, 139, 402, 69, 661, 661, 58, 138, 139,
1871 141, 428, 138, 139, 431, 66, 67, 68, 69, 70,
1872 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1873 81, 82, 83, 141, 85, 86, 87, 654, 89, 90,
1874 91, 92, 138, 139, 138, 139, 138, 139, 123, 138,
1875 139, 138, 139, 137, 105, 865, 663, 30, 31, 138,
1876 139, 112, 479, 137, 784, 138, 139, 787, 138, 139,
1877 138, 139, 138, 139, 123, 508, 542, 520, 138, 139,
1878 712, 713, 937, 938, 805, 806, 123, 123, 746, 57,
1879 746, 746, 140, 140, 140, 140, 140, 140, 140, 140,
1880 30, 140, 140, 30, 154, 527, 140, 140, 140, 140,
1881 140, 140, 140, 140, 580, 140, 140, 30, 89, 141,
1882 140, 30, 140, 140, 147, 558, 559, 560, 527, 746,
1883 140, 140, 140, 140, 140, 138, 141, 156, 140, 140,
1884 140, 140, 762, 576, 577, 578, 579, 140, 140, 58,
1885 140, 140, 140, 137, 93, 32, 32, 66, 67, 68,
1886 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1887 79, 80, 81, 82, 617, 32, 85, 86, 87, 30,
1888 89, 30, 91, 92, 30, 93, 140, 145, 621, 847,
1889 141, 847, 847, 913, 30, 88, 105, 663, 138, 819,
1890 145, 31, 822, 112, 31, 825, 32, 32, 30, 137,
1891 930, 143, 137, 30, 872, 140, 872, 872, 32, 144,
1892 145, 146, 147, 148, 149, 150, 151, 152, 153, 143,
1893 155, 32, 157, 158, 32, 32, 138, 680, 139, 143,
1894 860, 140, 138, 141, 138, 140, 126, 12, 140, 139,
1895 141, 138, 28, 29, 30, 143, 680, 143, 89, 137,
1896 30, 140, 137, 696, 697, 885, 699, 700, 701, 702,
1897 703, 704, 705, 706, 707, 708, 709, 710, 54, 138,
1898 900, 57, 58, 903, 138, 154, 141, 140, 140, 30,
1899 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
1900 76, 77, 78, 79, 80, 81, 82, 111, 84, 85,
1901 86, 87, 93, 89, 143, 91, 92, 32, 784, 95,
1902 96, 787, 143, 32, 32, 143, 106, 143, 140, 105,
1903 138, 107, 142, 64, 110, 137, 112, 143, 145, 154,
1904 151, 137, 808, 137, 30, 137, 137, 140, 143, 28,
1905 29, 30, 142, 30, 154, 154, 141, 139, 137, 93,
1906 138, 138, 137, 151, 138, 154, 142, 140, 140, 140,
1907 30, 155, 30, 45, 143, 54, 143, 820, 57, 58,
1908 143, 143, 143, 137, 143, 44, 808, 66, 67, 68,
1909 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1910 79, 80, 81, 82, 155, 84, 85, 86, 87, 33,
1911 89, 143, 91, 92, 143, 137, 95, 96, 138, 156,
1912 43, 138, 1, 156, 336, 342, 105, 345, 107, 895,
1913 333, 110, 339, 112, 877, 622, 556, 348, 581, 408,
1914 412, 405, 418, 430, 392, 436, 389, 913, 433, 378,
1915 383, 648, 783, 368, 652, 365, 661, 55, 3, 209,
1916 11, 12, 603, 352, 930, 746, 606, 272, 872, 20,
1917 868, 810, 905, 24, 809, 542, 480, 28, 29, 30,
1918 807, 563, 915, 34, 35, 36, 37, 38, 39, 40,
1919 41, 42, 925, 276, 185, 46, 47, 48, 49, -1,
1920 -1, -1, 935, 54, -1, -1, 57, 58, 59, 60,
1921 61, 62, 63, -1, 65, 66, 67, 68, 69, 70,
1922 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1923 81, 82, 83, 84, 85, 86, 87, -1, 89, 90,
1924 91, 92, -1, -1, 95, 96, -1, -1, -1, -1,
1925 -1, -1, -1, -1, 105, -1, 107, -1, 109, 110,
1926 -1, 112, -1, -1, 115, -1, -1, -1, -1, -1,
1927 -1, -1, -1, -1, -1, -1, -1, -1, -1, 11,
1928 12, -1, -1, -1, -1, -1, -1, -1, 20, -1,
1929 -1, 142, 24, -1, -1, -1, 28, 29, 30, -1,
1930 151, -1, 34, 35, 36, 37, 38, 39, 40, 41,
1931 42, -1, -1, -1, 46, 47, 48, 49, -1, -1,
1932 -1, -1, 54, -1, -1, 57, 58, 59, 60, 61,
1933 62, 63, -1, 65, 66, 67, 68, 69, 70, 71,
1934 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1935 82, 83, 84, 85, 86, 87, -1, 89, 90, 91,
1936 92, -1, -1, 95, 96, -1, -1, -1, -1, -1,
1937 -1, -1, -1, 105, -1, 107, -1, 109, 110, -1,
1938 112, -1, 3, 115, 5, 6, 7, 8, 9, 10,
1939 11, -1, 13, -1, -1, -1, 17, 18, 19, -1,
1940 21, 22, 23, -1, 25, 26, -1, 28, 29, 30,
1941 -1, -1, -1, -1, -1, -1, -1, -1, -1, 151,
1942 -1, -1, -1, -1, -1, -1, -1, -1, -1, 50,
1943 51, 52, 53, 54, 55, 56, 57, 58, -1, -1,
1944 -1, -1, -1, -1, -1, 66, 67, 68, 69, 70,
1945 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1946 81, 82, 30, 84, 85, 86, 87, -1, 89, -1,
1947 91, 92, -1, -1, 95, 96, 97, 98, 99, 100,
1948 -1, -1, -1, -1, 105, -1, 107, -1, -1, 110,
1949 58, 112, 113, 114, -1, 116, -1, -1, 66, 67,
1950 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1951 78, 79, 80, 81, 82, 83, -1, 85, 86, 87,
1952 30, 89, -1, 91, 92, -1, -1, -1, -1, -1,
1953 -1, -1, -1, -1, -1, -1, -1, 105, -1, -1,
1954 -1, -1, -1, -1, 112, -1, -1, -1, 58, -1,
1955 -1, -1, -1, -1, -1, -1, 66, 67, 68, 69,
1956 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1957 80, 81, 82, 30, -1, 85, 86, 87, -1, 89,
1958 -1, 91, 92, -1, -1, -1, -1, -1, -1, -1,
1959 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1960 -1, 58, 112, -1, -1, -1, -1, -1, -1, 66,
1961 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1962 77, 78, 79, 80, 81, 82, -1, -1, 85, 86,
1963 87, -1, -1, -1, 91, 92, -1, -1, -1, -1,
1964 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1965 -1, -1, -1, -1, -1, 112
1966 };
1967
1968 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1969 symbol of state STATE-NUM. */
1970 static const yytype_uint16 yystos[] =
1971 {
1972 0, 160, 161, 162, 0, 161, 3, 5, 6, 7,
1973 8, 9, 10, 11, 13, 17, 18, 19, 21, 22,
1974 23, 25, 26, 28, 29, 30, 50, 51, 52, 53,
1975 54, 55, 56, 57, 58, 66, 67, 68, 69, 70,
1976 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1977 81, 82, 84, 85, 86, 87, 89, 91, 92, 95,
1978 96, 97, 98, 99, 100, 105, 107, 110, 112, 113,
1979 114, 116, 163, 164, 165, 169, 173, 177, 181, 185,
1980 188, 194, 196, 202, 206, 210, 214, 218, 222, 223,
1981 227, 231, 235, 239, 246, 256, 260, 264, 265, 266,
1982 267, 279, 281, 282, 283, 284, 285, 286, 287, 298,
1983 304, 319, 320, 321, 325, 326, 329, 331, 332, 361,
1984 385, 389, 393, 137, 32, 137, 166, 32, 137, 170,
1985 32, 137, 174, 30, 137, 178, 30, 137, 182, 27,
1986 302, 303, 302, 30, 137, 299, 302, 302, 302, 302,
1987 302, 302, 302, 58, 393, 137, 31, 137, 257, 31,
1988 137, 261, 302, 302, 302, 30, 31, 137, 247, 254,
1989 137, 240, 254, 319, 319, 69, 57, 58, 306, 72,
1990 67, 68, 69, 72, 320, 393, 389, 30, 215, 207,
1991 30, 137, 211, 32, 137, 224, 389, 319, 152, 137,
1992 228, 254, 137, 232, 254, 137, 236, 319, 152, 87,
1993 26, 330, 30, 105, 392, 123, 136, 186, 187, 123,
1994 167, 168, 123, 171, 172, 123, 175, 176, 123, 179,
1995 180, 123, 183, 184, 302, 27, 29, 119, 125, 300,
1996 301, 302, 319, 148, 366, 219, 123, 124, 258, 259,
1997 123, 262, 263, 120, 121, 123, 131, 132, 133, 134,
1998 135, 249, 250, 141, 251, 248, 123, 241, 242, 141,
1999 243, 333, 327, 30, 307, 69, 392, 30, 137, 203,
2000 141, 141, 123, 212, 213, 122, 128, 129, 130, 225,
2001 226, 137, 137, 189, 389, 394, 123, 229, 230, 123,
2002 233, 234, 123, 237, 238, 394, 321, 393, 332, 137,
2003 366, 137, 140, 144, 145, 146, 147, 148, 149, 150,
2004 151, 152, 153, 155, 157, 158, 362, 147, 149, 391,
2005 140, 140, 138, 139, 140, 138, 139, 140, 138, 139,
2006 140, 138, 139, 140, 138, 139, 140, 138, 139, 140,
2007 140, 138, 139, 30, 367, 368, 195, 30, 144, 220,
2008 221, 307, 140, 140, 138, 139, 140, 138, 139, 140,
2009 140, 140, 140, 140, 140, 140, 140, 138, 139, 4,
2010 12, 218, 222, 252, 253, 289, 293, 140, 138, 139,
2011 218, 222, 244, 245, 293, 154, 335, 335, 366, 391,
2012 366, 147, 141, 204, 30, 216, 217, 30, 208, 209,
2013 140, 138, 139, 140, 140, 140, 140, 138, 139, 374,
2014 375, 376, 389, 390, 319, 366, 139, 153, 140, 138,
2015 139, 140, 138, 139, 140, 138, 139, 153, 366, 374,
2016 141, 386, 138, 137, 140, 140, 140, 140, 140, 140,
2017 140, 140, 140, 152, 140, 153, 156, 140, 140, 137,
2018 89, 30, 32, 349, 93, 187, 32, 168, 32, 172,
2019 32, 176, 30, 180, 30, 184, 30, 93, 301, 140,
2020 139, 148, 141, 198, 30, 88, 138, 145, 31, 102,
2021 103, 322, 259, 31, 263, 32, 32, 254, 322, 322,
2022 322, 322, 30, 250, 137, 290, 32, 137, 294, 142,
2023 253, 254, 242, 142, 245, 59, 60, 61, 336, 337,
2024 338, 366, 366, 305, 143, 30, 164, 205, 331, 143,
2025 142, 217, 142, 209, 349, 213, 32, 32, 32, 32,
2026 226, 138, 139, 307, 140, 313, 138, 141, 190, 389,
2027 254, 230, 254, 234, 319, 238, 197, 138, 14, 15,
2028 16, 218, 222, 387, 388, 143, 389, 140, 140, 374,
2029 30, 32, 93, 254, 369, 368, 24, 46, 47, 48,
2030 90, 199, 200, 201, 218, 222, 267, 276, 280, 304,
2031 30, 144, 307, 126, 291, 292, 117, 128, 295, 296,
2032 302, 143, 143, 139, 319, 334, 328, 141, 293, 297,
2033 138, 142, 164, 89, 363, 376, 366, 137, 314, 317,
2034 318, 108, 191, 192, 193, 218, 222, 267, 198, 363,
2035 302, 302, 302, 142, 388, 138, 138, 154, 302, 302,
2036 302, 302, 389, 142, 200, 30, 140, 138, 139, 140,
2037 140, 138, 139, 337, 141, 339, 339, 30, 218, 222,
2038 308, 309, 310, 137, 111, 364, 319, 145, 146, 147,
2039 148, 149, 150, 315, 144, 145, 146, 147, 149, 151,
2040 316, 302, 142, 192, 364, 143, 363, 93, 255, 30,
2041 143, 32, 292, 32, 32, 296, 11, 20, 30, 34,
2042 35, 36, 37, 38, 39, 40, 41, 42, 47, 48,
2043 49, 59, 60, 61, 62, 63, 65, 83, 90, 109,
2044 115, 151, 188, 202, 218, 222, 267, 268, 269, 270,
2045 271, 272, 273, 274, 275, 276, 277, 278, 280, 288,
2046 293, 304, 325, 326, 329, 332, 340, 341, 342, 351,
2047 353, 354, 356, 361, 377, 380, 382, 383, 385, 143,
2048 143, 140, 312, 142, 310, 394, 106, 395, 138, 317,
2049 32, 93, 94, 101, 104, 141, 319, 322, 323, 393,
2050 143, 395, 364, 145, 137, 302, 302, 137, 302, 302,
2051 302, 302, 302, 302, 302, 302, 302, 302, 302, 302,
2052 64, 350, 350, 350, 154, 378, 379, 352, 384, 381,
2053 355, 137, 343, 30, 142, 341, 317, 366, 143, 138,
2054 137, 140, 365, 142, 137, 365, 395, 255, 374, 374,
2055 154, 154, 154, 83, 380, 380, 353, 361, 389, 382,
2056 30, 356, 118, 123, 127, 344, 345, 141, 346, 137,
2057 139, 311, 366, 319, 396, 93, 366, 314, 324, 366,
2058 365, 138, 138, 30, 140, 140, 140, 138, 139, 218,
2059 222, 293, 347, 348, 138, 143, 138, 139, 155, 359,
2060 138, 139, 359, 366, 363, 395, 30, 349, 30, 345,
2061 142, 348, 395, 297, 319, 360, 143, 314, 143, 359,
2062 395, 366, 143, 365, 389, 45, 372, 297, 143, 366,
2063 155, 357, 366, 137, 302, 44, 371, 372, 372, 359,
2064 358, 143, 143, 374, 302, 33, 373, 371, 371, 143,
2065 137, 297, 372, 138, 302, 43, 370, 373, 373, 297,
2066 374, 372, 371, 156, 302, 370, 370, 372, 138, 371,
2067 373, 371, 156
2068 };
2069
2070 #define yyerrok (yyerrstatus = 0)
2071 #define yyclearin (yychar = YYEMPTY)
2072 #define YYEMPTY (-2)
2073 #define YYEOF 0
2074
2075 #define YYACCEPT goto yyacceptlab
2076 #define YYABORT goto yyabortlab
2077 #define YYERROR goto yyerrorlab
2078
2079
2080 /* Like YYERROR except do call yyerror. This remains here temporarily
2081 to ease the transition to the new meaning of YYERROR, for GCC.
2082 Once GCC version 2 has supplanted version 1, this can go. */
2083
2084 #define YYFAIL goto yyerrlab
2085
2086 #define YYRECOVERING() (!!yyerrstatus)
2087
2088 #define YYBACKUP(Token, Value) \
2089 do \
2090 if (yychar == YYEMPTY && yylen == 1) \
2091 { \
2092 yychar = (Token); \
2093 yylval = (Value); \
2094 yytoken = YYTRANSLATE (yychar); \
2095 YYPOPSTACK (1); \
2096 goto yybackup; \
2097 } \
2098 else \
2099 { \
2100 yyerror (YY_("syntax error: cannot back up")); \
2101 YYERROR; \
2102 } \
2103 while (YYID (0))
2104
2105
2106 #define YYTERROR 1
2107 #define YYERRCODE 256
2108
2109
2110 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2111 If N is 0, then set CURRENT to the empty location which ends
2112 the previous symbol: RHS[0] (always defined). */
2113
2114 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
2115 #ifndef YYLLOC_DEFAULT
2116 # define YYLLOC_DEFAULT(Current, Rhs, N) \
2117 do \
2118 if (YYID (N)) \
2119 { \
2120 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2121 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2122 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2123 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2124 } \
2125 else \
2126 { \
2127 (Current).first_line = (Current).last_line = \
2128 YYRHSLOC (Rhs, 0).last_line; \
2129 (Current).first_column = (Current).last_column = \
2130 YYRHSLOC (Rhs, 0).last_column; \
2131 } \
2132 while (YYID (0))
2133 #endif
2134
2135
2136 /* YY_LOCATION_PRINT -- Print the location on the stream.
2137 This macro was not mandated originally: define only if we know
2138 we won't break user code: when these are the locations we know. */
2139
2140 #ifndef YY_LOCATION_PRINT
2141 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
2142 # define YY_LOCATION_PRINT(File, Loc) \
2143 fprintf (File, "%d.%d-%d.%d", \
2144 (Loc).first_line, (Loc).first_column, \
2145 (Loc).last_line, (Loc).last_column)
2146 # else
2147 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2148 # endif
2149 #endif
2150
2151
2152 /* YYLEX -- calling `yylex' with the right arguments. */
2153
2154 #ifdef YYLEX_PARAM
2155 # define YYLEX yylex (YYLEX_PARAM)
2156 #else
2157 # define YYLEX yylex ()
2158 #endif
2159
2160 /* Enable debugging if requested. */
2161 #if YYDEBUG
2162
2163 # ifndef YYFPRINTF
2164 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2165 # define YYFPRINTF fprintf
2166 # endif
2167
2168 # define YYDPRINTF(Args) \
2169 do { \
2170 if (yydebug) \
2171 YYFPRINTF Args; \
2172 } while (YYID (0))
2173
2174 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2175 do { \
2176 if (yydebug) \
2177 { \
2178 YYFPRINTF (stderr, "%s ", Title); \
2179 yy_symbol_print (stderr, \
2180 Type, Value); \
2181 YYFPRINTF (stderr, "\n"); \
2182 } \
2183 } while (YYID (0))
2184
2185
2186 /*--------------------------------.
2187 | Print this symbol on YYOUTPUT. |
2188 `--------------------------------*/
2189
2190 /*ARGSUSED*/
2191 #if (defined __STDC__ || defined __C99__FUNC__ \
2192 || defined __cplusplus || defined _MSC_VER)
2193 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)2194 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2195 #else
2196 static void
2197 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
2198 FILE *yyoutput;
2199 int yytype;
2200 YYSTYPE const * const yyvaluep;
2201 #endif
2202 {
2203 if (!yyvaluep)
2204 return;
2205 # ifdef YYPRINT
2206 if (yytype < YYNTOKENS)
2207 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2208 # else
2209 YYUSE (yyoutput);
2210 # endif
2211 switch (yytype)
2212 {
2213 default:
2214 break;
2215 }
2216 }
2217
2218
2219 /*--------------------------------.
2220 | Print this symbol on YYOUTPUT. |
2221 `--------------------------------*/
2222
2223 #if (defined __STDC__ || defined __C99__FUNC__ \
2224 || defined __cplusplus || defined _MSC_VER)
2225 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)2226 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
2227 #else
2228 static void
2229 yy_symbol_print (yyoutput, yytype, yyvaluep)
2230 FILE *yyoutput;
2231 int yytype;
2232 YYSTYPE const * const yyvaluep;
2233 #endif
2234 {
2235 if (yytype < YYNTOKENS)
2236 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2237 else
2238 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2239
2240 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
2241 YYFPRINTF (yyoutput, ")");
2242 }
2243
2244 /*------------------------------------------------------------------.
2245 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
2246 | TOP (included). |
2247 `------------------------------------------------------------------*/
2248
2249 #if (defined __STDC__ || defined __C99__FUNC__ \
2250 || defined __cplusplus || defined _MSC_VER)
2251 static void
yy_stack_print(yytype_int16 * bottom,yytype_int16 * top)2252 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
2253 #else
2254 static void
2255 yy_stack_print (bottom, top)
2256 yytype_int16 *bottom;
2257 yytype_int16 *top;
2258 #endif
2259 {
2260 YYFPRINTF (stderr, "Stack now");
2261 for (; bottom <= top; ++bottom)
2262 YYFPRINTF (stderr, " %d", *bottom);
2263 YYFPRINTF (stderr, "\n");
2264 }
2265
2266 # define YY_STACK_PRINT(Bottom, Top) \
2267 do { \
2268 if (yydebug) \
2269 yy_stack_print ((Bottom), (Top)); \
2270 } while (YYID (0))
2271
2272
2273 /*------------------------------------------------.
2274 | Report that the YYRULE is going to be reduced. |
2275 `------------------------------------------------*/
2276
2277 #if (defined __STDC__ || defined __C99__FUNC__ \
2278 || defined __cplusplus || defined _MSC_VER)
2279 static void
yy_reduce_print(YYSTYPE * yyvsp,int yyrule)2280 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
2281 #else
2282 static void
2283 yy_reduce_print (yyvsp, yyrule)
2284 YYSTYPE *yyvsp;
2285 int yyrule;
2286 #endif
2287 {
2288 int yynrhs = yyr2[yyrule];
2289 int yyi;
2290 unsigned long int yylno = yyrline[yyrule];
2291 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
2292 yyrule - 1, yylno);
2293 /* The symbols being reduced. */
2294 for (yyi = 0; yyi < yynrhs; yyi++)
2295 {
2296 fprintf (stderr, " $%d = ", yyi + 1);
2297 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
2298 &(yyvsp[(yyi + 1) - (yynrhs)])
2299 );
2300 fprintf (stderr, "\n");
2301 }
2302 }
2303
2304 # define YY_REDUCE_PRINT(Rule) \
2305 do { \
2306 if (yydebug) \
2307 yy_reduce_print (yyvsp, Rule); \
2308 } while (YYID (0))
2309
2310 /* Nonzero means print parse trace. It is left uninitialized so that
2311 multiple parsers can coexist. */
2312 int yydebug;
2313 #else /* !YYDEBUG */
2314 # define YYDPRINTF(Args)
2315 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2316 # define YY_STACK_PRINT(Bottom, Top)
2317 # define YY_REDUCE_PRINT(Rule)
2318 #endif /* !YYDEBUG */
2319
2320
2321 /* YYINITDEPTH -- initial size of the parser's stacks. */
2322 #ifndef YYINITDEPTH
2323 # define YYINITDEPTH 200
2324 #endif
2325
2326 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2327 if the built-in stack extension method is used).
2328
2329 Do not make this value too large; the results are undefined if
2330 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2331 evaluated with infinite-precision integer arithmetic. */
2332
2333 #ifndef YYMAXDEPTH
2334 # define YYMAXDEPTH 10000
2335 #endif
2336
2337
2338
2339 #if YYERROR_VERBOSE
2340
2341 # ifndef yystrlen
2342 # if defined __GLIBC__ && defined _STRING_H
2343 # define yystrlen strlen
2344 # else
2345 /* Return the length of YYSTR. */
2346 #if (defined __STDC__ || defined __C99__FUNC__ \
2347 || defined __cplusplus || defined _MSC_VER)
2348 static YYSIZE_T
yystrlen(const char * yystr)2349 yystrlen (const char *yystr)
2350 #else
2351 static YYSIZE_T
2352 yystrlen (yystr)
2353 const char *yystr;
2354 #endif
2355 {
2356 YYSIZE_T yylen;
2357 for (yylen = 0; yystr[yylen]; yylen++)
2358 continue;
2359 return yylen;
2360 }
2361 # endif
2362 # endif
2363
2364 # ifndef yystpcpy
2365 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
2366 # define yystpcpy stpcpy
2367 # else
2368 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2369 YYDEST. */
2370 #if (defined __STDC__ || defined __C99__FUNC__ \
2371 || defined __cplusplus || defined _MSC_VER)
2372 static char *
yystpcpy(char * yydest,const char * yysrc)2373 yystpcpy (char *yydest, const char *yysrc)
2374 #else
2375 static char *
2376 yystpcpy (yydest, yysrc)
2377 char *yydest;
2378 const char *yysrc;
2379 #endif
2380 {
2381 char *yyd = yydest;
2382 const char *yys = yysrc;
2383
2384 while ((*yyd++ = *yys++) != '\0')
2385 continue;
2386
2387 return yyd - 1;
2388 }
2389 # endif
2390 # endif
2391
2392 # ifndef yytnamerr
2393 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2394 quotes and backslashes, so that it's suitable for yyerror. The
2395 heuristic is that double-quoting is unnecessary unless the string
2396 contains an apostrophe, a comma, or backslash (other than
2397 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2398 null, do not copy; instead, return the length of what the result
2399 would have been. */
2400 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)2401 yytnamerr (char *yyres, const char *yystr)
2402 {
2403 if (*yystr == '"')
2404 {
2405 YYSIZE_T yyn = 0;
2406 char const *yyp = yystr;
2407
2408 for (;;)
2409 switch (*++yyp)
2410 {
2411 case '\'':
2412 case ',':
2413 goto do_not_strip_quotes;
2414
2415 case '\\':
2416 if (*++yyp != '\\')
2417 goto do_not_strip_quotes;
2418 /* Fall through. */
2419 default:
2420 if (yyres)
2421 yyres[yyn] = *yyp;
2422 yyn++;
2423 break;
2424
2425 case '"':
2426 if (yyres)
2427 yyres[yyn] = '\0';
2428 return yyn;
2429 }
2430 do_not_strip_quotes: ;
2431 }
2432
2433 if (! yyres)
2434 return yystrlen (yystr);
2435
2436 return yystpcpy (yyres, yystr) - yyres;
2437 }
2438 # endif
2439
2440 /* Copy into YYRESULT an error message about the unexpected token
2441 YYCHAR while in state YYSTATE. Return the number of bytes copied,
2442 including the terminating null byte. If YYRESULT is null, do not
2443 copy anything; just return the number of bytes that would be
2444 copied. As a special case, return 0 if an ordinary "syntax error"
2445 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
2446 size calculation. */
2447 static YYSIZE_T
yysyntax_error(char * yyresult,int yystate,int yychar)2448 yysyntax_error (char *yyresult, int yystate, int yychar)
2449 {
2450 int yyn = yypact[yystate];
2451
2452 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
2453 return 0;
2454 else
2455 {
2456 int yytype = YYTRANSLATE (yychar);
2457 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
2458 YYSIZE_T yysize = yysize0;
2459 YYSIZE_T yysize1;
2460 int yysize_overflow = 0;
2461 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
2462 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2463 int yyx;
2464
2465 # if 0
2466 /* This is so xgettext sees the translatable formats that are
2467 constructed on the fly. */
2468 YY_("syntax error, unexpected %s");
2469 YY_("syntax error, unexpected %s, expecting %s");
2470 YY_("syntax error, unexpected %s, expecting %s or %s");
2471 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
2472 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
2473 # endif
2474 char *yyfmt;
2475 char const *yyf;
2476 static char const yyunexpected[] = "syntax error, unexpected %s";
2477 static char const yyexpecting[] = ", expecting %s";
2478 static char const yyor[] = " or %s";
2479 char yyformat[sizeof yyunexpected
2480 + sizeof yyexpecting - 1
2481 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
2482 * (sizeof yyor - 1))];
2483 char const *yyprefix = yyexpecting;
2484
2485 /* Start YYX at -YYN if negative to avoid negative indexes in
2486 YYCHECK. */
2487 int yyxbegin = yyn < 0 ? -yyn : 0;
2488
2489 /* Stay within bounds of both yycheck and yytname. */
2490 int yychecklim = YYLAST - yyn + 1;
2491 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2492 int yycount = 1;
2493
2494 yyarg[0] = yytname[yytype];
2495 yyfmt = yystpcpy (yyformat, yyunexpected);
2496
2497 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2498 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2499 {
2500 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2501 {
2502 yycount = 1;
2503 yysize = yysize0;
2504 yyformat[sizeof yyunexpected - 1] = '\0';
2505 break;
2506 }
2507 yyarg[yycount++] = yytname[yyx];
2508 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
2509 yysize_overflow |= (yysize1 < yysize);
2510 yysize = yysize1;
2511 yyfmt = yystpcpy (yyfmt, yyprefix);
2512 yyprefix = yyor;
2513 }
2514
2515 yyf = YY_(yyformat);
2516 yysize1 = yysize + yystrlen (yyf);
2517 yysize_overflow |= (yysize1 < yysize);
2518 yysize = yysize1;
2519
2520 if (yysize_overflow)
2521 return YYSIZE_MAXIMUM;
2522
2523 if (yyresult)
2524 {
2525 /* Avoid sprintf, as that infringes on the user's name space.
2526 Don't have undefined behavior even if the translation
2527 produced a string with the wrong number of "%s"s. */
2528 char *yyp = yyresult;
2529 int yyi = 0;
2530 while ((*yyp = *yyf) != '\0')
2531 {
2532 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
2533 {
2534 yyp += yytnamerr (yyp, yyarg[yyi++]);
2535 yyf += 2;
2536 }
2537 else
2538 {
2539 yyp++;
2540 yyf++;
2541 }
2542 }
2543 }
2544 return yysize;
2545 }
2546 }
2547 #endif /* YYERROR_VERBOSE */
2548
2549
2550 /*-----------------------------------------------.
2551 | Release the memory associated to this symbol. |
2552 `-----------------------------------------------*/
2553
2554 /*ARGSUSED*/
2555 #if (defined __STDC__ || defined __C99__FUNC__ \
2556 || defined __cplusplus || defined _MSC_VER)
2557 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)2558 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2559 #else
2560 static void
2561 yydestruct (yymsg, yytype, yyvaluep)
2562 const char *yymsg;
2563 int yytype;
2564 YYSTYPE *yyvaluep;
2565 #endif
2566 {
2567 YYUSE (yyvaluep);
2568
2569 if (!yymsg)
2570 yymsg = "Deleting";
2571 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2572
2573 switch (yytype)
2574 {
2575
2576 default:
2577 break;
2578 }
2579 }
2580
2581
2582 /* Prevent warnings from -Wmissing-prototypes. */
2583
2584 #ifdef YYPARSE_PARAM
2585 #if defined __STDC__ || defined __cplusplus
2586 int yyparse (void *YYPARSE_PARAM);
2587 #else
2588 int yyparse ();
2589 #endif
2590 #else /* ! YYPARSE_PARAM */
2591 #if defined __STDC__ || defined __cplusplus
2592 int yyparse (void);
2593 #else
2594 int yyparse ();
2595 #endif
2596 #endif /* ! YYPARSE_PARAM */
2597
2598
2599
2600 /* The look-ahead symbol. */
2601 int yychar;
2602
2603 /* The semantic value of the look-ahead symbol. */
2604 YYSTYPE yylval;
2605
2606 /* Number of syntax errors so far. */
2607 int yynerrs;
2608
2609
2610
2611 /*----------.
2612 | yyparse. |
2613 `----------*/
2614
2615 #ifdef YYPARSE_PARAM
2616 #if (defined __STDC__ || defined __C99__FUNC__ \
2617 || defined __cplusplus || defined _MSC_VER)
2618 int
yyparse(void * YYPARSE_PARAM)2619 yyparse (void *YYPARSE_PARAM)
2620 #else
2621 int
2622 yyparse (YYPARSE_PARAM)
2623 void *YYPARSE_PARAM;
2624 #endif
2625 #else /* ! YYPARSE_PARAM */
2626 #if (defined __STDC__ || defined __C99__FUNC__ \
2627 || defined __cplusplus || defined _MSC_VER)
2628 int
2629 yyparse (void)
2630 #else
2631 int
2632 yyparse ()
2633
2634 #endif
2635 #endif
2636 {
2637
2638 int yystate;
2639 int yyn;
2640 int yyresult;
2641 /* Number of tokens to shift before error messages enabled. */
2642 int yyerrstatus;
2643 /* Look-ahead token as an internal (translated) token number. */
2644 int yytoken = 0;
2645 #if YYERROR_VERBOSE
2646 /* Buffer for error messages, and its allocated size. */
2647 char yymsgbuf[128];
2648 char *yymsg = yymsgbuf;
2649 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
2650 #endif
2651
2652 /* Three stacks and their tools:
2653 `yyss': related to states,
2654 `yyvs': related to semantic values,
2655 `yyls': related to locations.
2656
2657 Refer to the stacks thru separate pointers, to allow yyoverflow
2658 to reallocate them elsewhere. */
2659
2660 /* The state stack. */
2661 yytype_int16 yyssa[YYINITDEPTH];
2662 yytype_int16 *yyss = yyssa;
2663 yytype_int16 *yyssp;
2664
2665 /* The semantic value stack. */
2666 YYSTYPE yyvsa[YYINITDEPTH];
2667 YYSTYPE *yyvs = yyvsa;
2668 YYSTYPE *yyvsp;
2669
2670
2671
2672 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
2673
2674 YYSIZE_T yystacksize = YYINITDEPTH;
2675
2676 /* The variables used to return semantic value and location from the
2677 action routines. */
2678 YYSTYPE yyval;
2679
2680
2681 /* The number of symbols on the RHS of the reduced rule.
2682 Keep to zero when no symbol should be popped. */
2683 int yylen = 0;
2684
2685 YYDPRINTF ((stderr, "Starting parse\n"));
2686
2687 yystate = 0;
2688 yyerrstatus = 0;
2689 yynerrs = 0;
2690 yychar = YYEMPTY; /* Cause a token to be read. */
2691
2692 /* Initialize stack pointers.
2693 Waste one element of value and location stack
2694 so that they stay on the same level as the state stack.
2695 The wasted elements are never initialized. */
2696
2697 yyssp = yyss;
2698 yyvsp = yyvs;
2699
2700 goto yysetstate;
2701
2702 /*------------------------------------------------------------.
2703 | yynewstate -- Push a new state, which is found in yystate. |
2704 `------------------------------------------------------------*/
2705 yynewstate:
2706 /* In all cases, when you get here, the value and location stacks
2707 have just been pushed. So pushing a state here evens the stacks. */
2708 yyssp++;
2709
2710 yysetstate:
2711 *yyssp = yystate;
2712
2713 if (yyss + yystacksize - 1 <= yyssp)
2714 {
2715 /* Get the current used size of the three stacks, in elements. */
2716 YYSIZE_T yysize = yyssp - yyss + 1;
2717
2718 #ifdef yyoverflow
2719 {
2720 /* Give user a chance to reallocate the stack. Use copies of
2721 these so that the &'s don't force the real ones into
2722 memory. */
2723 YYSTYPE *yyvs1 = yyvs;
2724 yytype_int16 *yyss1 = yyss;
2725
2726
2727 /* Each stack pointer address is followed by the size of the
2728 data in use in that stack, in bytes. This used to be a
2729 conditional around just the two extra args, but that might
2730 be undefined if yyoverflow is a macro. */
2731 yyoverflow (YY_("memory exhausted"),
2732 &yyss1, yysize * sizeof (*yyssp),
2733 &yyvs1, yysize * sizeof (*yyvsp),
2734
2735 &yystacksize);
2736
2737 yyss = yyss1;
2738 yyvs = yyvs1;
2739 }
2740 #else /* no yyoverflow */
2741 # ifndef YYSTACK_RELOCATE
2742 goto yyexhaustedlab;
2743 # else
2744 /* Extend the stack our own way. */
2745 if (YYMAXDEPTH <= yystacksize)
2746 goto yyexhaustedlab;
2747 yystacksize *= 2;
2748 if (YYMAXDEPTH < yystacksize)
2749 yystacksize = YYMAXDEPTH;
2750
2751 {
2752 yytype_int16 *yyss1 = yyss;
2753 union yyalloc *yyptr =
2754 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2755 if (! yyptr)
2756 goto yyexhaustedlab;
2757 YYSTACK_RELOCATE (yyss);
2758 YYSTACK_RELOCATE (yyvs);
2759
2760 # undef YYSTACK_RELOCATE
2761 if (yyss1 != yyssa)
2762 YYSTACK_FREE (yyss1);
2763 }
2764 # endif
2765 #endif /* no yyoverflow */
2766
2767 yyssp = yyss + yysize - 1;
2768 yyvsp = yyvs + yysize - 1;
2769
2770
2771 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2772 (unsigned long int) yystacksize));
2773
2774 if (yyss + yystacksize - 1 <= yyssp)
2775 YYABORT;
2776 }
2777
2778 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2779
2780 goto yybackup;
2781
2782 /*-----------.
2783 | yybackup. |
2784 `-----------*/
2785 yybackup:
2786
2787 /* Do appropriate processing given the current state. Read a
2788 look-ahead token if we need one and don't already have one. */
2789
2790 /* First try to decide what to do without reference to look-ahead token. */
2791 yyn = yypact[yystate];
2792 if (yyn == YYPACT_NINF)
2793 goto yydefault;
2794
2795 /* Not known => get a look-ahead token if don't already have one. */
2796
2797 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
2798 if (yychar == YYEMPTY)
2799 {
2800 YYDPRINTF ((stderr, "Reading a token: "));
2801 yychar = YYLEX;
2802 }
2803
2804 if (yychar <= YYEOF)
2805 {
2806 yychar = yytoken = YYEOF;
2807 YYDPRINTF ((stderr, "Now at end of input.\n"));
2808 }
2809 else
2810 {
2811 yytoken = YYTRANSLATE (yychar);
2812 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
2813 }
2814
2815 /* If the proper action on seeing token YYTOKEN is to reduce or to
2816 detect an error, take that action. */
2817 yyn += yytoken;
2818 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2819 goto yydefault;
2820 yyn = yytable[yyn];
2821 if (yyn <= 0)
2822 {
2823 if (yyn == 0 || yyn == YYTABLE_NINF)
2824 goto yyerrlab;
2825 yyn = -yyn;
2826 goto yyreduce;
2827 }
2828
2829 if (yyn == YYFINAL)
2830 YYACCEPT;
2831
2832 /* Count tokens shifted since error; after three, turn off error
2833 status. */
2834 if (yyerrstatus)
2835 yyerrstatus--;
2836
2837 /* Shift the look-ahead token. */
2838 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2839
2840 /* Discard the shifted token unless it is eof. */
2841 if (yychar != YYEOF)
2842 yychar = YYEMPTY;
2843
2844 yystate = yyn;
2845 *++yyvsp = yylval;
2846
2847 goto yynewstate;
2848
2849
2850 /*-----------------------------------------------------------.
2851 | yydefault -- do the default action for the current state. |
2852 `-----------------------------------------------------------*/
2853 yydefault:
2854 yyn = yydefact[yystate];
2855 if (yyn == 0)
2856 goto yyerrlab;
2857 goto yyreduce;
2858
2859
2860 /*-----------------------------.
2861 | yyreduce -- Do a reduction. |
2862 `-----------------------------*/
2863 yyreduce:
2864 /* yyn is the number of a rule to reduce with. */
2865 yylen = yyr2[yyn];
2866
2867 /* If YYLEN is nonzero, implement the default value of the action:
2868 `$$ = $1'.
2869
2870 Otherwise, the following line sets YYVAL to garbage.
2871 This behavior is undocumented and Bison
2872 users should not rely upon it. Assigning to YYVAL
2873 unconditionally makes the parser a bit smaller, and it avoids a
2874 GCC warning that YYVAL may be used uninitialized. */
2875 yyval = yyvsp[1-yylen];
2876
2877
2878 YY_REDUCE_PRINT (yyn);
2879 switch (yyn)
2880 {
2881 case 4:
2882 #line 550 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2883 {
2884 /*
2885 * We don't do these in parserEOF() because the parser is reading
2886 * ahead and that would be too early.
2887 */
2888
2889 if (previousFile != NULL)
2890 {
2891 handleEOF();
2892
2893 if (currentContext.prevmod != NULL)
2894 handleEOM();
2895
2896 free(previousFile);
2897 previousFile = NULL;
2898 }
2899 }
2900 break;
2901
2902 case 49:
2903 #line 614 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2904 {
2905 if (notSkipping())
2906 {
2907 classDef *scope = currentScope();
2908
2909 if (scope == NULL)
2910 yyerror("%TypeHeaderCode can only be used in a namespace, class or mapped type");
2911
2912 appendCodeBlock(&scope->iff->hdrcode, (yyvsp[(1) - (1)].codeb));
2913 }
2914 }
2915 break;
2916
2917 case 50:
2918 #line 627 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2919 {
2920 if (notSkipping())
2921 currentModule->defdocstringfmt = convertFormat((yyvsp[(2) - (2)].defdocstringfmt).name);
2922 }
2923 break;
2924
2925 case 51:
2926 #line 633 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2927 {
2928 resetLexerState();
2929
2930 (yyval.defdocstringfmt).name = (yyvsp[(1) - (1)].text);
2931 }
2932 break;
2933
2934 case 52:
2935 #line 638 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2936 {
2937 (yyval.defdocstringfmt) = (yyvsp[(2) - (3)].defdocstringfmt);
2938 }
2939 break;
2940
2941 case 54:
2942 #line 644 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2943 {
2944 (yyval.defdocstringfmt) = (yyvsp[(1) - (3)].defdocstringfmt);
2945
2946 switch ((yyvsp[(3) - (3)].defdocstringfmt).token)
2947 {
2948 case TK_NAME: (yyval.defdocstringfmt).name = (yyvsp[(3) - (3)].defdocstringfmt).name; break;
2949 }
2950 }
2951 break;
2952
2953 case 55:
2954 #line 654 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2955 {
2956 (yyval.defdocstringfmt).token = TK_NAME;
2957
2958 (yyval.defdocstringfmt).name = (yyvsp[(3) - (3)].text);
2959 }
2960 break;
2961
2962 case 56:
2963 #line 661 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2964 {
2965 if (notSkipping())
2966 currentModule->defdocstringsig = convertSignature((yyvsp[(2) - (2)].defdocstringsig).name);
2967 }
2968 break;
2969
2970 case 57:
2971 #line 667 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2972 {
2973 resetLexerState();
2974
2975 (yyval.defdocstringsig).name = (yyvsp[(1) - (1)].text);
2976 }
2977 break;
2978
2979 case 58:
2980 #line 672 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2981 {
2982 (yyval.defdocstringsig) = (yyvsp[(2) - (3)].defdocstringsig);
2983 }
2984 break;
2985
2986 case 60:
2987 #line 678 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
2988 {
2989 (yyval.defdocstringsig) = (yyvsp[(1) - (3)].defdocstringsig);
2990
2991 switch ((yyvsp[(3) - (3)].defdocstringsig).token)
2992 {
2993 case TK_NAME: (yyval.defdocstringsig).name = (yyvsp[(3) - (3)].defdocstringsig).name; break;
2994 }
2995 }
2996 break;
2997
2998 case 61:
2999 #line 688 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3000 {
3001 (yyval.defdocstringsig).token = TK_NAME;
3002
3003 (yyval.defdocstringsig).name = (yyvsp[(3) - (3)].text);
3004 }
3005 break;
3006
3007 case 62:
3008 #line 695 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3009 {
3010 if (notSkipping())
3011 {
3012 if ((currentModule->encoding = convertEncoding((yyvsp[(2) - (2)].defencoding).name)) == no_type)
3013 yyerror("The %DefaultEncoding name must be one of \"ASCII\", \"Latin-1\", \"UTF-8\" or \"None\"");
3014 }
3015 }
3016 break;
3017
3018 case 63:
3019 #line 704 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3020 {
3021 resetLexerState();
3022
3023 (yyval.defencoding).name = (yyvsp[(1) - (1)].text);
3024 }
3025 break;
3026
3027 case 64:
3028 #line 709 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3029 {
3030 (yyval.defencoding) = (yyvsp[(2) - (3)].defencoding);
3031 }
3032 break;
3033
3034 case 66:
3035 #line 715 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3036 {
3037 (yyval.defencoding) = (yyvsp[(1) - (3)].defencoding);
3038
3039 switch ((yyvsp[(3) - (3)].defencoding).token)
3040 {
3041 case TK_NAME: (yyval.defencoding).name = (yyvsp[(3) - (3)].defencoding).name; break;
3042 }
3043 }
3044 break;
3045
3046 case 67:
3047 #line 725 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3048 {
3049 (yyval.defencoding).token = TK_NAME;
3050
3051 (yyval.defencoding).name = (yyvsp[(3) - (3)].text);
3052 }
3053 break;
3054
3055 case 68:
3056 #line 732 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3057 {
3058 /*
3059 * Note that %Plugin is internal in SIP v4. The current thinking
3060 * is that it won't be needed for SIP v5.
3061 */
3062
3063 if (notSkipping())
3064 appendString(¤tSpec->plugins, (yyvsp[(2) - (2)].plugin).name);
3065 }
3066 break;
3067
3068 case 69:
3069 #line 743 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3070 {
3071 resetLexerState();
3072
3073 (yyval.plugin).name = (yyvsp[(1) - (1)].text);
3074 }
3075 break;
3076
3077 case 70:
3078 #line 748 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3079 {
3080 (yyval.plugin) = (yyvsp[(2) - (3)].plugin);
3081 }
3082 break;
3083
3084 case 72:
3085 #line 754 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3086 {
3087 (yyval.plugin) = (yyvsp[(1) - (3)].plugin);
3088
3089 switch ((yyvsp[(3) - (3)].plugin).token)
3090 {
3091 case TK_NAME: (yyval.plugin).name = (yyvsp[(3) - (3)].plugin).name; break;
3092 }
3093 }
3094 break;
3095
3096 case 73:
3097 #line 764 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3098 {
3099 (yyval.plugin).token = TK_NAME;
3100
3101 (yyval.plugin).name = (yyvsp[(3) - (3)].text);
3102 }
3103 break;
3104
3105 case 74:
3106 #line 771 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3107 {
3108 if ((yyvsp[(2) - (3)].veh).name == NULL)
3109 yyerror("%VirtualErrorHandler must have a 'name' argument");
3110
3111 if (notSkipping())
3112 {
3113 virtErrorHandler *veh, **tailp;
3114
3115 /* Check there isn't already a handler with the same name. */
3116 for (tailp = ¤tSpec->errorhandlers; (veh = *tailp) != NULL; tailp = &veh->next)
3117 if (strcmp(veh->name, (yyvsp[(2) - (3)].veh).name) == 0)
3118 break;
3119
3120 if (veh != NULL)
3121 yyerror("A virtual error handler with that name has already been defined");
3122
3123 veh = sipMalloc(sizeof (virtErrorHandler));
3124
3125 veh->name = (yyvsp[(2) - (3)].veh).name;
3126 appendCodeBlock(&veh->code, (yyvsp[(3) - (3)].codeb));
3127 veh->mod = currentModule;
3128 veh->index = -1;
3129 veh->next = NULL;
3130
3131 *tailp = veh;
3132 }
3133 }
3134 break;
3135
3136 case 75:
3137 #line 800 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3138 {
3139 resetLexerState();
3140
3141 (yyval.veh).name = (yyvsp[(1) - (1)].text);
3142 }
3143 break;
3144
3145 case 76:
3146 #line 805 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3147 {
3148 (yyval.veh) = (yyvsp[(2) - (3)].veh);
3149 }
3150 break;
3151
3152 case 78:
3153 #line 811 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3154 {
3155 (yyval.veh) = (yyvsp[(1) - (3)].veh);
3156
3157 switch ((yyvsp[(3) - (3)].veh).token)
3158 {
3159 case TK_NAME: (yyval.veh).name = (yyvsp[(3) - (3)].veh).name; break;
3160 }
3161 }
3162 break;
3163
3164 case 79:
3165 #line 821 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3166 {
3167 (yyval.veh).token = TK_NAME;
3168
3169 (yyval.veh).name = (yyvsp[(3) - (3)].text);
3170 }
3171 break;
3172
3173 case 80:
3174 #line 828 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3175 {
3176 deprecated("The %API directive is deprecated and will be removed in v6");
3177
3178 if (notSkipping())
3179 {
3180 apiVersionRangeDef *avd;
3181
3182 if (findAPI(currentSpec, (yyvsp[(3) - (4)].api).name) != NULL)
3183 yyerror("The API name in the %API directive has already been defined");
3184
3185 if ((yyvsp[(3) - (4)].api).version < 1)
3186 yyerror("The version number in the %API directive must be greater than or equal to 1");
3187
3188 avd = sipMalloc(sizeof (apiVersionRangeDef));
3189
3190 avd->api_name = cacheName(currentSpec, (yyvsp[(3) - (4)].api).name);
3191 avd->from = (yyvsp[(3) - (4)].api).version;
3192 avd->to = -1;
3193
3194 avd->next = currentModule->api_versions;
3195 currentModule->api_versions = avd;
3196
3197 if (inMainModule())
3198 setIsUsedName(avd->api_name);
3199 }
3200 }
3201 break;
3202
3203 case 82:
3204 #line 857 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3205 {
3206 (yyval.api) = (yyvsp[(1) - (3)].api);
3207
3208 switch ((yyvsp[(3) - (3)].api).token)
3209 {
3210 case TK_NAME: (yyval.api).name = (yyvsp[(3) - (3)].api).name; break;
3211 case TK_VERSION: (yyval.api).version = (yyvsp[(3) - (3)].api).version; break;
3212 }
3213 }
3214 break;
3215
3216 case 83:
3217 #line 868 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3218 {
3219 (yyval.api).token = TK_NAME;
3220
3221 (yyval.api).name = (yyvsp[(3) - (3)].text);
3222 (yyval.api).version = 0;
3223 }
3224 break;
3225
3226 case 84:
3227 #line 874 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3228 {
3229 (yyval.api).token = TK_VERSION;
3230
3231 (yyval.api).name = NULL;
3232 (yyval.api).version = (yyvsp[(3) - (3)].number);
3233 }
3234 break;
3235
3236 case 85:
3237 #line 882 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3238 {
3239 if (notSkipping())
3240 {
3241 static const char *annos[] = {
3242 "Default",
3243 "PyName",
3244 NULL
3245 };
3246
3247 exceptionDef *xd;
3248 const char *pyname;
3249
3250 checkAnnos(&(yyvsp[(4) - (5)].optflags), annos);
3251
3252 if (currentSpec->genc)
3253 yyerror("%Exception not allowed in a C module");
3254
3255 if ((yyvsp[(5) - (5)].exception).raise_code == NULL)
3256 yyerror("%Exception must have a %RaiseCode sub-directive");
3257
3258 pyname = getPythonName(currentModule, &(yyvsp[(4) - (5)].optflags), scopedNameTail((yyvsp[(2) - (5)].scpvalp)));
3259
3260 checkAttributes(currentSpec, currentModule, NULL, NULL,
3261 pyname, FALSE);
3262
3263 xd = findException(currentSpec, (yyvsp[(2) - (5)].scpvalp), TRUE);
3264
3265 if (xd->cd != NULL)
3266 yyerror("%Exception name has already been seen as a class name - it must be defined before being used");
3267
3268 if (xd->iff->module != NULL)
3269 yyerror("The %Exception has already been defined");
3270
3271 /* Complete the definition. */
3272 xd->iff->module = currentModule;
3273 appendCodeBlock(&xd->iff->hdrcode, (yyvsp[(5) - (5)].exception).type_header_code);
3274 xd->pyname = pyname;
3275 xd->bibase = (yyvsp[(3) - (5)].exceptionbase).bibase;
3276 xd->base = (yyvsp[(3) - (5)].exceptionbase).base;
3277 appendCodeBlock(&xd->raisecode, (yyvsp[(5) - (5)].exception).raise_code);
3278
3279 if (getOptFlag(&(yyvsp[(4) - (5)].optflags), "Default", bool_flag) != NULL)
3280 currentModule->defexception = xd;
3281 }
3282 }
3283 break;
3284
3285 case 86:
3286 #line 929 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3287 {
3288 (yyval.exceptionbase).bibase = NULL;
3289 (yyval.exceptionbase).base = NULL;
3290 }
3291 break;
3292
3293 case 87:
3294 #line 933 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3295 {
3296 exceptionDef *xd;
3297
3298 (yyval.exceptionbase).bibase = NULL;
3299 (yyval.exceptionbase).base = NULL;
3300
3301 /* See if it is a defined exception. */
3302 for (xd = currentSpec->exceptions; xd != NULL; xd = xd->next)
3303 if (compareScopedNames(xd->iff->fqcname, (yyvsp[(2) - (3)].scpvalp)) == 0)
3304 {
3305 (yyval.exceptionbase).base = xd;
3306 break;
3307 }
3308
3309 if (xd == NULL && (yyvsp[(2) - (3)].scpvalp)->next == NULL && strncmp((yyvsp[(2) - (3)].scpvalp)->name, "SIP_", 4) == 0)
3310 {
3311 /* See if it is a builtin exception. */
3312
3313 static char *builtins[] = {
3314 "BaseException",
3315 "Exception",
3316 "StopIteration",
3317 "GeneratorExit",
3318 "ArithmeticError",
3319 "LookupError",
3320 "StandardError", /* Python v2. */
3321
3322 "AssertionError",
3323 "AttributeError",
3324 "BufferError",
3325 "EOFError",
3326 "FloatingPointError",
3327 "OSError",
3328 "ImportError",
3329 "IndexError",
3330 "KeyError",
3331 "KeyboardInterrupt",
3332 "MemoryError",
3333 "NameError",
3334 "OverflowError",
3335 "RuntimeError",
3336 "NotImplementedError",
3337 "SyntaxError",
3338 "IndentationError",
3339 "TabError",
3340 "ReferenceError",
3341 "SystemError",
3342 "SystemExit",
3343 "TypeError",
3344 "UnboundLocalError",
3345 "UnicodeError",
3346 "UnicodeEncodeError",
3347 "UnicodeDecodeError",
3348 "UnicodeTranslateError",
3349 "ValueError",
3350 "ZeroDivisionError",
3351 "EnvironmentError", /* Python v2. */
3352 "IOError", /* Python v2. */
3353 "WindowsError", /* Python v2. */
3354 "VMSError", /* Python v2. */
3355
3356 "BlockingIOError",
3357 "BrokenPipeError",
3358 "ChildProcessError",
3359 "ConnectionError",
3360 "ConnectionAbortedError",
3361 "ConnectionRefusedError",
3362 "ConnectionResetError",
3363 "FileExistsError",
3364 "FileNotFoundError",
3365 "InterruptedError",
3366 "IsADirectoryError",
3367 "NotADirectoryError",
3368 "PermissionError",
3369 "ProcessLookupError",
3370 "TimeoutError",
3371
3372 "Warning",
3373 "UserWarning",
3374 "DeprecationWarning",
3375 "PendingDeprecationWarning",
3376 "SyntaxWarning",
3377 "RuntimeWarning",
3378 "FutureWarning",
3379 "ImportWarning",
3380 "UnicodeWarning",
3381 "BytesWarning",
3382 "ResourceWarning",
3383
3384 NULL
3385 };
3386
3387 char **cp;
3388
3389 for (cp = builtins; *cp != NULL; ++cp)
3390 if (strcmp((yyvsp[(2) - (3)].scpvalp)->name + 4, *cp) == 0)
3391 {
3392 (yyval.exceptionbase).bibase = *cp;
3393 break;
3394 }
3395 }
3396
3397 if ((yyval.exceptionbase).bibase == NULL && (yyval.exceptionbase).base == NULL)
3398 yyerror("Unknown exception base type");
3399 }
3400 break;
3401
3402 case 88:
3403 #line 1040 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3404 {
3405 (yyval.exception) = (yyvsp[(2) - (4)].exception);
3406 }
3407 break;
3408
3409 case 90:
3410 #line 1046 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3411 {
3412 (yyval.exception) = (yyvsp[(1) - (2)].exception);
3413
3414 switch ((yyvsp[(2) - (2)].exception).token)
3415 {
3416 case TK_RAISECODE: (yyval.exception).raise_code = (yyvsp[(2) - (2)].exception).raise_code; break;
3417 case TK_TYPEHEADERCODE: (yyval.exception).type_header_code = (yyvsp[(2) - (2)].exception).type_header_code; break;
3418 }
3419 }
3420 break;
3421
3422 case 91:
3423 #line 1057 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3424 {
3425 (yyval.exception).token = TK_IF;
3426 }
3427 break;
3428
3429 case 92:
3430 #line 1060 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3431 {
3432 (yyval.exception).token = TK_END;
3433 }
3434 break;
3435
3436 case 93:
3437 #line 1063 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3438 {
3439 if (notSkipping())
3440 {
3441 (yyval.exception).token = TK_RAISECODE;
3442 (yyval.exception).raise_code = (yyvsp[(1) - (1)].codeb);
3443 }
3444 else
3445 {
3446 (yyval.exception).token = 0;
3447 (yyval.exception).raise_code = NULL;
3448 }
3449
3450 (yyval.exception).type_header_code = NULL;
3451 }
3452 break;
3453
3454 case 94:
3455 #line 1077 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3456 {
3457 if (notSkipping())
3458 {
3459 (yyval.exception).token = TK_TYPEHEADERCODE;
3460 (yyval.exception).type_header_code = (yyvsp[(1) - (1)].codeb);
3461 }
3462 else
3463 {
3464 (yyval.exception).token = 0;
3465 (yyval.exception).type_header_code = NULL;
3466 }
3467
3468 (yyval.exception).raise_code = NULL;
3469 }
3470 break;
3471
3472 case 95:
3473 #line 1093 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3474 {
3475 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
3476 }
3477 break;
3478
3479 case 96:
3480 #line 1098 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3481 {
3482 if (notSkipping())
3483 {
3484 static const char *annos[] = {
3485 "AllowNone",
3486 "API",
3487 "NoRelease",
3488 "PyName",
3489 "TypeHint",
3490 "TypeHintIn",
3491 "TypeHintOut",
3492 "TypeHintValue",
3493 NULL
3494 };
3495
3496 checkAnnos(&(yyvsp[(3) - (3)].optflags), annos);
3497
3498 currentMappedType = newMappedType(currentSpec, &(yyvsp[(2) - (3)].memArg), &(yyvsp[(3) - (3)].optflags));
3499 }
3500 }
3501 break;
3502
3503 case 98:
3504 #line 1120 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3505 {
3506 if (notSkipping())
3507 {
3508 static const char *annos[] = {
3509 "AllowNone",
3510 "NoRelease",
3511 "TypeHint",
3512 "TypeHintIn",
3513 "TypeHintOut",
3514 "TypeHintValue",
3515 NULL
3516 };
3517
3518 int a;
3519 mappedTypeTmplDef *mtt;
3520 ifaceFileDef *iff;
3521
3522 checkAnnos(&(yyvsp[(4) - (4)].optflags), annos);
3523
3524 if (currentSpec->genc)
3525 yyerror("%MappedType templates not allowed in a C module");
3526
3527 /*
3528 * Check the template arguments are basic types or simple
3529 * names.
3530 */
3531 for (a = 0; a < (yyvsp[(1) - (4)].signature).nrArgs; ++a)
3532 {
3533 argDef *ad = &(yyvsp[(1) - (4)].signature).args[a];
3534
3535 if (ad->atype == defined_type && ad->u.snd->next != NULL)
3536 yyerror("%MappedType template arguments must be simple names");
3537 }
3538
3539 if ((yyvsp[(3) - (4)].memArg).atype != template_type)
3540 yyerror("%MappedType template must map a template type");
3541
3542 (yyvsp[(3) - (4)].memArg).u.td->fqname = fullyQualifiedName((yyvsp[(3) - (4)].memArg).u.td->fqname);
3543
3544 /* Check a template hasn't already been provided. */
3545 for (mtt = currentSpec->mappedtypetemplates; mtt != NULL; mtt = mtt->next)
3546 if (compareScopedNames(mtt->mt->type.u.td->fqname, (yyvsp[(3) - (4)].memArg).u.td->fqname ) == 0 && sameTemplateSignature(&mtt->mt->type.u.td->types, &(yyvsp[(3) - (4)].memArg).u.td->types, TRUE))
3547 yyerror("%MappedType template for this type has already been defined");
3548
3549 (yyvsp[(3) - (4)].memArg).nrderefs = 0;
3550 (yyvsp[(3) - (4)].memArg).argflags = 0;
3551
3552 mtt = sipMalloc(sizeof (mappedTypeTmplDef));
3553
3554 mtt->sig = (yyvsp[(1) - (4)].signature);
3555 mtt->mt = allocMappedType(currentSpec, &(yyvsp[(3) - (4)].memArg));
3556 mappedTypeAnnos(mtt->mt, &(yyvsp[(4) - (4)].optflags));
3557 mtt->next = currentSpec->mappedtypetemplates;
3558
3559 currentSpec->mappedtypetemplates = mtt;
3560
3561 currentMappedType = mtt->mt;
3562
3563 /* Create a dummy interface file. */
3564 iff = sipMalloc(sizeof (ifaceFileDef));
3565 iff->hdrcode = NULL;
3566 mtt->mt->iff = iff;
3567 }
3568 }
3569 break;
3570
3571 case 100:
3572 #line 1186 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3573 {
3574 if (notSkipping())
3575 {
3576 if (currentMappedType->convfromcode == NULL)
3577 yyerror("%MappedType must have a %ConvertFromTypeCode directive");
3578
3579 if (currentMappedType->convtocode == NULL)
3580 yyerror("%MappedType must have a %ConvertToTypeCode directive");
3581
3582 currentMappedType = NULL;
3583 }
3584 }
3585 break;
3586
3587 case 105:
3588 #line 1206 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3589 {
3590 if (notSkipping())
3591 appendCodeBlock(¤tMappedType->iff->hdrcode, (yyvsp[(1) - (1)].codeb));
3592 }
3593 break;
3594
3595 case 106:
3596 #line 1210 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3597 {
3598 if (notSkipping())
3599 appendCodeBlock(¤tMappedType->typecode, (yyvsp[(1) - (1)].codeb));
3600 }
3601 break;
3602
3603 case 107:
3604 #line 1214 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3605 {
3606 if (notSkipping())
3607 {
3608 if (currentMappedType->convfromcode != NULL)
3609 yyerror("%MappedType has more than one %ConvertFromTypeCode directive");
3610
3611 appendCodeBlock(¤tMappedType->convfromcode, (yyvsp[(2) - (2)].codeb));
3612 }
3613 }
3614 break;
3615
3616 case 108:
3617 #line 1223 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3618 {
3619 if (notSkipping())
3620 {
3621 if (currentMappedType->convtocode != NULL)
3622 yyerror("%MappedType has more than one %ConvertToTypeCode directive");
3623
3624 appendCodeBlock(¤tMappedType->convtocode, (yyvsp[(2) - (2)].codeb));
3625 }
3626 }
3627 break;
3628
3629 case 109:
3630 #line 1232 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3631 {
3632 if (notSkipping())
3633 {
3634 if (currentMappedType->instancecode != NULL)
3635 yyerror("%MappedType has more than one %InstanceCode directive");
3636
3637 appendCodeBlock(¤tMappedType->instancecode, (yyvsp[(1) - (1)].codeb));
3638 }
3639 }
3640 break;
3641
3642 case 112:
3643 #line 1245 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3644 {
3645 if (notSkipping())
3646 {
3647 applyTypeFlags(currentModule, &(yyvsp[(2) - (14)].memArg), &(yyvsp[(9) - (14)].optflags));
3648
3649 (yyvsp[(5) - (14)].signature).result = (yyvsp[(2) - (14)].memArg);
3650
3651 newFunction(currentSpec, currentModule, NULL, NULL,
3652 currentMappedType, 0, TRUE, FALSE, FALSE, FALSE, (yyvsp[(3) - (14)].text),
3653 &(yyvsp[(5) - (14)].signature), (yyvsp[(7) - (14)].number), FALSE, &(yyvsp[(9) - (14)].optflags), (yyvsp[(14) - (14)].codeb), NULL, NULL, (yyvsp[(8) - (14)].throwlist), (yyvsp[(10) - (14)].optsignature), (yyvsp[(12) - (14)].docstr),
3654 FALSE, (yyvsp[(13) - (14)].codeb));
3655 }
3656 }
3657 break;
3658
3659 case 113:
3660 #line 1260 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3661 {
3662 if (currentSpec -> genc)
3663 yyerror("namespace definition not allowed in a C module");
3664
3665 if (notSkipping())
3666 {
3667 classDef *ns, *c_scope;
3668 ifaceFileDef *scope;
3669
3670 if ((c_scope = currentScope()) != NULL)
3671 scope = c_scope->iff;
3672 else
3673 scope = NULL;
3674
3675 ns = newClass(currentSpec, namespace_iface, NULL,
3676 text2scopedName(scope, (yyvsp[(2) - (2)].text)), NULL, NULL, NULL, NULL);
3677
3678 pushScope(ns);
3679
3680 sectionFlags = 0;
3681 }
3682 }
3683 break;
3684
3685 case 114:
3686 #line 1281 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3687 {
3688 if (notSkipping())
3689 {
3690 if (inMainModule())
3691 {
3692 classDef *ns = currentScope();
3693
3694 setIsUsedName(ns->iff->name);
3695 setIsUsedName(ns->pyname);
3696 }
3697
3698 popScope();
3699 }
3700 }
3701 break;
3702
3703 case 119:
3704 #line 1305 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3705 {
3706 if (notSkipping())
3707 {
3708 qualDef *qd;
3709
3710 for (qd = currentModule->qualifiers; qd != NULL; qd = qd->next)
3711 if (qd->qtype == platform_qualifier)
3712 yyerror("%Platforms has already been defined for this module");
3713 }
3714 }
3715 break;
3716
3717 case 120:
3718 #line 1315 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3719 {
3720 if (notSkipping())
3721 {
3722 qualDef *qd;
3723 int nrneeded;
3724
3725 /* Check that exactly one platform in the set was requested. */
3726 nrneeded = 0;
3727
3728 for (qd = currentModule->qualifiers; qd != NULL; qd = qd->next)
3729 if (qd->qtype == platform_qualifier && selectedQualifier(neededQualifiers, qd))
3730 ++nrneeded;
3731
3732 if (nrneeded > 1)
3733 yyerror("No more than one of these %Platforms must be specified with the -t flag");
3734 }
3735 }
3736 break;
3737
3738 case 123:
3739 #line 1338 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3740 {
3741 newQualifier(currentModule, -1, 0, notSkipping(), (yyvsp[(1) - (1)].text),
3742 platform_qualifier);
3743 }
3744 break;
3745
3746 case 124:
3747 #line 1344 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3748 {
3749 newQualifier(currentModule, -1, 0, notSkipping(), (yyvsp[(2) - (2)].feature).name,
3750 feature_qualifier);
3751 }
3752 break;
3753
3754 case 125:
3755 #line 1350 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3756 {
3757 resetLexerState();
3758
3759 (yyval.feature).name = (yyvsp[(1) - (1)].text);
3760 }
3761 break;
3762
3763 case 126:
3764 #line 1355 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3765 {
3766 (yyval.feature) = (yyvsp[(2) - (3)].feature);
3767 }
3768 break;
3769
3770 case 128:
3771 #line 1361 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3772 {
3773 (yyval.feature) = (yyvsp[(1) - (3)].feature);
3774
3775 switch ((yyvsp[(3) - (3)].feature).token)
3776 {
3777 case TK_NAME: (yyval.feature).name = (yyvsp[(3) - (3)].feature).name; break;
3778 }
3779 }
3780 break;
3781
3782 case 129:
3783 #line 1371 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3784 {
3785 (yyval.feature).token = TK_NAME;
3786
3787 (yyval.feature).name = (yyvsp[(3) - (3)].text);
3788 }
3789 break;
3790
3791 case 130:
3792 #line 1378 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3793 {
3794 currentTimelineOrder = 0;
3795 }
3796 break;
3797
3798 case 131:
3799 #line 1381 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3800 {
3801 if (notSkipping())
3802 {
3803 qualDef *qd;
3804 int nrneeded;
3805
3806 /*
3807 * Check that exactly one time slot in the set was requested.
3808 */
3809 nrneeded = 0;
3810
3811 for (qd = currentModule->qualifiers; qd != NULL; qd = qd->next)
3812 if (qd->qtype == time_qualifier && selectedQualifier(neededQualifiers, qd))
3813 ++nrneeded;
3814
3815 if (nrneeded > 1)
3816 yyerror("At most one of this %Timeline must be specified with the -t flag");
3817
3818 currentModule->nrtimelines++;
3819 }
3820 }
3821 break;
3822
3823 case 134:
3824 #line 1408 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3825 {
3826 newQualifier(currentModule, currentModule->nrtimelines,
3827 currentTimelineOrder++, TRUE, (yyvsp[(1) - (1)].text), time_qualifier);
3828 }
3829 break;
3830
3831 case 135:
3832 #line 1414 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3833 {
3834 currentPlatforms = NULL;
3835 }
3836 break;
3837
3838 case 136:
3839 #line 1416 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3840 {
3841 if (stackPtr >= MAX_NESTED_IF)
3842 yyerror("Internal error: increase the value of MAX_NESTED_IF");
3843
3844 /* Nested %Ifs are implicit logical ands. */
3845
3846 if (stackPtr > 0)
3847 (yyvsp[(4) - (5)].boolean) = ((yyvsp[(4) - (5)].boolean) && skipStack[stackPtr - 1]);
3848
3849 skipStack[stackPtr] = (yyvsp[(4) - (5)].boolean);
3850
3851 platformStack[stackPtr] = currentPlatforms;
3852
3853 ++stackPtr;
3854 }
3855 break;
3856
3857 case 137:
3858 #line 1433 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3859 {
3860 (yyval.boolean) = platOrFeature((yyvsp[(1) - (1)].text), FALSE);
3861 }
3862 break;
3863
3864 case 138:
3865 #line 1436 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3866 {
3867 (yyval.boolean) = platOrFeature((yyvsp[(2) - (2)].text), TRUE);
3868 }
3869 break;
3870
3871 case 139:
3872 #line 1439 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3873 {
3874 (yyval.boolean) = (platOrFeature((yyvsp[(3) - (3)].text), FALSE) || (yyvsp[(1) - (3)].boolean));
3875 }
3876 break;
3877
3878 case 140:
3879 #line 1442 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3880 {
3881 (yyval.boolean) = (platOrFeature((yyvsp[(4) - (4)].text), TRUE) || (yyvsp[(1) - (4)].boolean));
3882 }
3883 break;
3884
3885 case 142:
3886 #line 1448 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3887 {
3888 (yyval.boolean) = timePeriod((yyvsp[(1) - (3)].text), (yyvsp[(3) - (3)].text));
3889 }
3890 break;
3891
3892 case 143:
3893 #line 1453 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3894 {
3895 if (stackPtr-- <= 0)
3896 yyerror("Too many %End directives");
3897
3898 currentPlatforms = (stackPtr == 0 ? NULL : platformStack[stackPtr - 1]);
3899 }
3900 break;
3901
3902 case 144:
3903 #line 1461 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3904 {
3905 if ((yyvsp[(2) - (2)].license).type == NULL)
3906 yyerror("%License must have a 'type' argument");
3907
3908 if (notSkipping())
3909 {
3910 currentModule->license = sipMalloc(sizeof (licenseDef));
3911
3912 currentModule->license->type = (yyvsp[(2) - (2)].license).type;
3913 currentModule->license->licensee = (yyvsp[(2) - (2)].license).licensee;
3914 currentModule->license->sig = (yyvsp[(2) - (2)].license).signature;
3915 currentModule->license->timestamp = (yyvsp[(2) - (2)].license).timestamp;
3916 }
3917 }
3918 break;
3919
3920 case 145:
3921 #line 1477 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3922 {
3923 resetLexerState();
3924
3925 (yyval.license).type = NULL;
3926 (yyval.license).licensee = NULL;
3927 (yyval.license).signature = NULL;
3928 (yyval.license).timestamp = NULL;
3929 }
3930 break;
3931
3932 case 146:
3933 #line 1485 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3934 {
3935 (yyval.license).type = (yyvsp[(1) - (1)].text);
3936 (yyval.license).licensee = NULL;
3937 (yyval.license).signature = NULL;
3938 (yyval.license).timestamp = NULL;
3939 }
3940 break;
3941
3942 case 147:
3943 #line 1491 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3944 {
3945 (yyval.license) = (yyvsp[(2) - (3)].license);
3946 }
3947 break;
3948
3949 case 149:
3950 #line 1497 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3951 {
3952 (yyval.license) = (yyvsp[(1) - (3)].license);
3953
3954 switch ((yyvsp[(3) - (3)].license).token)
3955 {
3956 case TK_TYPE: (yyval.license).type = (yyvsp[(3) - (3)].license).type; break;
3957 case TK_LICENSEE: (yyval.license).licensee = (yyvsp[(3) - (3)].license).licensee; break;
3958 case TK_SIGNATURE: (yyval.license).signature = (yyvsp[(3) - (3)].license).signature; break;
3959 case TK_TIMESTAMP: (yyval.license).timestamp = (yyvsp[(3) - (3)].license).timestamp; break;
3960 }
3961 }
3962 break;
3963
3964 case 150:
3965 #line 1510 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3966 {
3967 (yyval.license).token = TK_NAME;
3968
3969 (yyval.license).type = (yyvsp[(3) - (3)].text);
3970 (yyval.license).licensee = NULL;
3971 (yyval.license).signature = NULL;
3972 (yyval.license).timestamp = NULL;
3973 }
3974 break;
3975
3976 case 151:
3977 #line 1518 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3978 {
3979 (yyval.license).token = TK_LICENSEE;
3980
3981 (yyval.license).type = NULL;
3982 (yyval.license).licensee = (yyvsp[(3) - (3)].text);
3983 (yyval.license).signature = NULL;
3984 (yyval.license).timestamp = NULL;
3985 }
3986 break;
3987
3988 case 152:
3989 #line 1526 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
3990 {
3991 (yyval.license).token = TK_SIGNATURE;
3992
3993 (yyval.license).type = NULL;
3994 (yyval.license).licensee = NULL;
3995 (yyval.license).signature = (yyvsp[(3) - (3)].text);
3996 (yyval.license).timestamp = NULL;
3997 }
3998 break;
3999
4000 case 153:
4001 #line 1534 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4002 {
4003 (yyval.license).token = TK_TIMESTAMP;
4004
4005 (yyval.license).type = NULL;
4006 (yyval.license).licensee = NULL;
4007 (yyval.license).signature = NULL;
4008 (yyval.license).timestamp = (yyvsp[(3) - (3)].text);
4009 }
4010 break;
4011
4012 case 154:
4013 #line 1544 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4014 {
4015 if (notSkipping())
4016 {
4017 if (currentModule->defmetatype != NULL)
4018 yyerror("%DefaultMetatype has already been defined for this module");
4019
4020 currentModule->defmetatype = cacheName(currentSpec, (yyvsp[(2) - (2)].defmetatype).name);
4021 }
4022 }
4023 break;
4024
4025 case 155:
4026 #line 1555 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4027 {
4028 resetLexerState();
4029
4030 (yyval.defmetatype).name = (yyvsp[(1) - (1)].text);
4031 }
4032 break;
4033
4034 case 156:
4035 #line 1560 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4036 {
4037 (yyval.defmetatype) = (yyvsp[(2) - (3)].defmetatype);
4038 }
4039 break;
4040
4041 case 158:
4042 #line 1566 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4043 {
4044 (yyval.defmetatype) = (yyvsp[(1) - (3)].defmetatype);
4045
4046 switch ((yyvsp[(3) - (3)].defmetatype).token)
4047 {
4048 case TK_NAME: (yyval.defmetatype).name = (yyvsp[(3) - (3)].defmetatype).name; break;
4049 }
4050 }
4051 break;
4052
4053 case 159:
4054 #line 1576 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4055 {
4056 (yyval.defmetatype).token = TK_NAME;
4057
4058 (yyval.defmetatype).name = (yyvsp[(3) - (3)].text);
4059 }
4060 break;
4061
4062 case 160:
4063 #line 1583 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4064 {
4065 if (notSkipping())
4066 {
4067 if (currentModule->defsupertype != NULL)
4068 yyerror("%DefaultSupertype has already been defined for this module");
4069
4070 currentModule->defsupertype = cacheName(currentSpec, (yyvsp[(2) - (2)].defsupertype).name);
4071 }
4072 }
4073 break;
4074
4075 case 161:
4076 #line 1594 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4077 {
4078 resetLexerState();
4079
4080 (yyval.defsupertype).name = (yyvsp[(1) - (1)].text);
4081 }
4082 break;
4083
4084 case 162:
4085 #line 1599 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4086 {
4087 (yyval.defsupertype) = (yyvsp[(2) - (3)].defsupertype);
4088 }
4089 break;
4090
4091 case 164:
4092 #line 1605 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4093 {
4094 (yyval.defsupertype) = (yyvsp[(1) - (3)].defsupertype);
4095
4096 switch ((yyvsp[(3) - (3)].defsupertype).token)
4097 {
4098 case TK_NAME: (yyval.defsupertype).name = (yyvsp[(3) - (3)].defsupertype).name; break;
4099 }
4100 }
4101 break;
4102
4103 case 165:
4104 #line 1615 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4105 {
4106 (yyval.defsupertype).token = TK_NAME;
4107
4108 (yyval.defsupertype).name = (yyvsp[(3) - (3)].text);
4109 }
4110 break;
4111
4112 case 166:
4113 #line 1622 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4114 {
4115 if (notSkipping())
4116 {
4117 classDef *ns;
4118
4119 ns = newClass(currentSpec, namespace_iface, NULL,
4120 fullyQualifiedName((yyvsp[(2) - (2)].hiddenns).name), NULL, NULL, NULL, NULL);
4121 setHiddenNamespace(ns);
4122 }
4123 }
4124 break;
4125
4126 case 167:
4127 #line 1634 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4128 {
4129 resetLexerState();
4130
4131 (yyval.hiddenns).name = (yyvsp[(1) - (1)].scpvalp);
4132 }
4133 break;
4134
4135 case 168:
4136 #line 1639 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4137 {
4138 (yyval.hiddenns) = (yyvsp[(2) - (3)].hiddenns);
4139 }
4140 break;
4141
4142 case 170:
4143 #line 1645 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4144 {
4145 (yyval.hiddenns) = (yyvsp[(1) - (3)].hiddenns);
4146
4147 switch ((yyvsp[(3) - (3)].hiddenns).token)
4148 {
4149 case TK_NAME: (yyval.hiddenns).name = (yyvsp[(3) - (3)].hiddenns).name; break;
4150 }
4151 }
4152 break;
4153
4154 case 171:
4155 #line 1655 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4156 {
4157 (yyval.hiddenns).token = TK_NAME;
4158
4159 (yyval.hiddenns).name = (yyvsp[(3) - (3)].scpvalp);
4160 }
4161 break;
4162
4163 case 172:
4164 #line 1662 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4165 {
4166 if (notSkipping())
4167 {
4168 /* Make sure this is the first mention of a module. */
4169 if (currentSpec->module != currentModule)
4170 yyerror("A %CompositeModule cannot be %Imported");
4171
4172 if (currentModule->fullname != NULL)
4173 yyerror("%CompositeModule must appear before any %Module directive");
4174
4175 setModuleName(currentSpec, currentModule, (yyvsp[(2) - (3)].compmodule).name);
4176 currentModule->docstring = (yyvsp[(3) - (3)].compmodule).docstring;
4177
4178 setIsComposite(currentModule);
4179 }
4180 }
4181 break;
4182
4183 case 173:
4184 #line 1680 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4185 {
4186 resetLexerState();
4187
4188 (yyval.compmodule).name = (yyvsp[(1) - (1)].text);
4189 }
4190 break;
4191
4192 case 174:
4193 #line 1685 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4194 {
4195 (yyval.compmodule) = (yyvsp[(2) - (3)].compmodule);
4196 }
4197 break;
4198
4199 case 176:
4200 #line 1691 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4201 {
4202 (yyval.compmodule) = (yyvsp[(1) - (3)].compmodule);
4203
4204 switch ((yyvsp[(3) - (3)].compmodule).token)
4205 {
4206 case TK_NAME: (yyval.compmodule).name = (yyvsp[(3) - (3)].compmodule).name; break;
4207 }
4208 }
4209 break;
4210
4211 case 177:
4212 #line 1701 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4213 {
4214 (yyval.compmodule).token = TK_NAME;
4215
4216 (yyval.compmodule).name = (yyvsp[(3) - (3)].text);
4217 }
4218 break;
4219
4220 case 178:
4221 #line 1708 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4222 {
4223 (yyval.compmodule).token = 0;
4224 (yyval.compmodule).docstring = NULL;
4225 }
4226 break;
4227
4228 case 179:
4229 #line 1712 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4230 {
4231 (yyval.compmodule) = (yyvsp[(2) - (4)].compmodule);
4232 }
4233 break;
4234
4235 case 181:
4236 #line 1718 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4237 {
4238 (yyval.compmodule) = (yyvsp[(1) - (2)].compmodule);
4239
4240 switch ((yyvsp[(2) - (2)].compmodule).token)
4241 {
4242 case TK_DOCSTRING: (yyval.compmodule).docstring = (yyvsp[(2) - (2)].compmodule).docstring; break;
4243 }
4244 }
4245 break;
4246
4247 case 182:
4248 #line 1728 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4249 {
4250 (yyval.compmodule).token = TK_IF;
4251 }
4252 break;
4253
4254 case 183:
4255 #line 1731 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4256 {
4257 (yyval.compmodule).token = TK_END;
4258 }
4259 break;
4260
4261 case 184:
4262 #line 1734 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4263 {
4264 if (notSkipping())
4265 {
4266 (yyval.compmodule).token = TK_DOCSTRING;
4267 (yyval.compmodule).docstring = (yyvsp[(1) - (1)].docstr);
4268 }
4269 else
4270 {
4271 (yyval.compmodule).token = 0;
4272 (yyval.compmodule).docstring = NULL;
4273 }
4274 }
4275 break;
4276
4277 case 185:
4278 #line 1748 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4279 {
4280 if ((yyvsp[(2) - (3)].module).name == NULL)
4281 yyerror("%Module must have a 'name' argument");
4282
4283 if (notSkipping())
4284 currentModule = configureModule(currentSpec, currentModule,
4285 currentContext.filename, (yyvsp[(2) - (3)].module).name, (yyvsp[(2) - (3)].module).c_module,
4286 (yyvsp[(2) - (3)].module).kwargs, (yyvsp[(2) - (3)].module).use_arg_names, (yyvsp[(2) - (3)].module).use_limited_api,
4287 (yyvsp[(2) - (3)].module).call_super_init, (yyvsp[(2) - (3)].module).all_raise_py_exc,
4288 (yyvsp[(2) - (3)].module).def_error_handler, (yyvsp[(3) - (3)].module).docstring);
4289 }
4290 break;
4291
4292 case 186:
4293 #line 1761 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4294 {resetLexerState();}
4295 break;
4296
4297 case 187:
4298 #line 1761 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4299 {
4300 (yyval.module).c_module = FALSE;
4301 (yyval.module).kwargs = defaultKwArgs;
4302 (yyval.module).name = (yyvsp[(1) - (2)].text);
4303 (yyval.module).use_arg_names = FALSE;
4304 (yyval.module).use_limited_api = FALSE;
4305 (yyval.module).all_raise_py_exc = FALSE;
4306 (yyval.module).call_super_init = -1;
4307 (yyval.module).def_error_handler = NULL;
4308 }
4309 break;
4310
4311 case 188:
4312 #line 1771 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4313 {
4314 (yyval.module) = (yyvsp[(2) - (3)].module);
4315 }
4316 break;
4317
4318 case 190:
4319 #line 1777 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4320 {
4321 (yyval.module) = (yyvsp[(1) - (3)].module);
4322
4323 switch ((yyvsp[(3) - (3)].module).token)
4324 {
4325 case TK_KWARGS: (yyval.module).kwargs = (yyvsp[(3) - (3)].module).kwargs; break;
4326 case TK_LANGUAGE: (yyval.module).c_module = (yyvsp[(3) - (3)].module).c_module; break;
4327 case TK_NAME: (yyval.module).name = (yyvsp[(3) - (3)].module).name; break;
4328 case TK_USEARGNAMES: (yyval.module).use_arg_names = (yyvsp[(3) - (3)].module).use_arg_names; break;
4329 case TK_USELIMITEDAPI: (yyval.module).use_limited_api = (yyvsp[(3) - (3)].module).use_limited_api; break;
4330 case TK_ALLRAISEPYEXC: (yyval.module).all_raise_py_exc = (yyvsp[(3) - (3)].module).all_raise_py_exc; break;
4331 case TK_CALLSUPERINIT: (yyval.module).call_super_init = (yyvsp[(3) - (3)].module).call_super_init; break;
4332 case TK_DEFERRORHANDLER: (yyval.module).def_error_handler = (yyvsp[(3) - (3)].module).def_error_handler; break;
4333 }
4334 }
4335 break;
4336
4337 case 191:
4338 #line 1794 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4339 {
4340 (yyval.module).token = TK_KWARGS;
4341
4342 (yyval.module).c_module = FALSE;
4343 (yyval.module).kwargs = convertKwArgs((yyvsp[(3) - (3)].text));
4344 (yyval.module).name = NULL;
4345 (yyval.module).use_arg_names = FALSE;
4346 (yyval.module).use_limited_api = FALSE;
4347 (yyval.module).all_raise_py_exc = FALSE;
4348 (yyval.module).call_super_init = -1;
4349 (yyval.module).def_error_handler = NULL;
4350 }
4351 break;
4352
4353 case 192:
4354 #line 1806 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4355 {
4356 (yyval.module).token = TK_LANGUAGE;
4357
4358 if (strcmp((yyvsp[(3) - (3)].text), "C++") == 0)
4359 (yyval.module).c_module = FALSE;
4360 else if (strcmp((yyvsp[(3) - (3)].text), "C") == 0)
4361 (yyval.module).c_module = TRUE;
4362 else
4363 yyerror("%Module 'language' argument must be either \"C++\" or \"C\"");
4364
4365 (yyval.module).kwargs = defaultKwArgs;
4366 (yyval.module).name = NULL;
4367 (yyval.module).use_arg_names = FALSE;
4368 (yyval.module).use_limited_api = FALSE;
4369 (yyval.module).all_raise_py_exc = FALSE;
4370 (yyval.module).call_super_init = -1;
4371 (yyval.module).def_error_handler = NULL;
4372 }
4373 break;
4374
4375 case 193:
4376 #line 1824 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4377 {
4378 (yyval.module).token = TK_NAME;
4379
4380 (yyval.module).c_module = FALSE;
4381 (yyval.module).kwargs = defaultKwArgs;
4382 (yyval.module).name = (yyvsp[(3) - (3)].text);
4383 (yyval.module).use_arg_names = FALSE;
4384 (yyval.module).use_limited_api = FALSE;
4385 (yyval.module).all_raise_py_exc = FALSE;
4386 (yyval.module).call_super_init = -1;
4387 (yyval.module).def_error_handler = NULL;
4388 }
4389 break;
4390
4391 case 194:
4392 #line 1836 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4393 {
4394 (yyval.module).token = TK_USEARGNAMES;
4395
4396 (yyval.module).c_module = FALSE;
4397 (yyval.module).kwargs = defaultKwArgs;
4398 (yyval.module).name = NULL;
4399 (yyval.module).use_arg_names = (yyvsp[(3) - (3)].boolean);
4400 (yyval.module).use_limited_api = FALSE;
4401 (yyval.module).all_raise_py_exc = FALSE;
4402 (yyval.module).call_super_init = -1;
4403 (yyval.module).def_error_handler = NULL;
4404 }
4405 break;
4406
4407 case 195:
4408 #line 1848 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4409 {
4410 (yyval.module).token = TK_USELIMITEDAPI;
4411
4412 (yyval.module).c_module = FALSE;
4413 (yyval.module).kwargs = defaultKwArgs;
4414 (yyval.module).name = NULL;
4415 (yyval.module).use_arg_names = FALSE;
4416 (yyval.module).use_limited_api = (yyvsp[(3) - (3)].boolean);
4417 (yyval.module).all_raise_py_exc = FALSE;
4418 (yyval.module).call_super_init = -1;
4419 (yyval.module).def_error_handler = NULL;
4420 }
4421 break;
4422
4423 case 196:
4424 #line 1860 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4425 {
4426 (yyval.module).token = TK_ALLRAISEPYEXC;
4427
4428 (yyval.module).c_module = FALSE;
4429 (yyval.module).kwargs = defaultKwArgs;
4430 (yyval.module).name = NULL;
4431 (yyval.module).use_arg_names = FALSE;
4432 (yyval.module).use_limited_api = FALSE;
4433 (yyval.module).all_raise_py_exc = (yyvsp[(3) - (3)].boolean);
4434 (yyval.module).call_super_init = -1;
4435 (yyval.module).def_error_handler = NULL;
4436 }
4437 break;
4438
4439 case 197:
4440 #line 1872 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4441 {
4442 (yyval.module).token = TK_CALLSUPERINIT;
4443
4444 (yyval.module).c_module = FALSE;
4445 (yyval.module).kwargs = defaultKwArgs;
4446 (yyval.module).name = NULL;
4447 (yyval.module).use_arg_names = FALSE;
4448 (yyval.module).use_limited_api = FALSE;
4449 (yyval.module).all_raise_py_exc = FALSE;
4450 (yyval.module).call_super_init = (yyvsp[(3) - (3)].boolean);
4451 (yyval.module).def_error_handler = NULL;
4452 }
4453 break;
4454
4455 case 198:
4456 #line 1884 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4457 {
4458 (yyval.module).token = TK_DEFERRORHANDLER;
4459
4460 (yyval.module).c_module = FALSE;
4461 (yyval.module).kwargs = defaultKwArgs;
4462 (yyval.module).name = NULL;
4463 (yyval.module).use_arg_names = FALSE;
4464 (yyval.module).use_limited_api = FALSE;
4465 (yyval.module).all_raise_py_exc = FALSE;
4466 (yyval.module).call_super_init = -1;
4467 (yyval.module).def_error_handler = (yyvsp[(3) - (3)].text);
4468 }
4469 break;
4470
4471 case 199:
4472 #line 1898 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4473 {
4474 (yyval.module).token = 0;
4475 (yyval.module).docstring = NULL;
4476 }
4477 break;
4478
4479 case 200:
4480 #line 1902 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4481 {
4482 (yyval.module) = (yyvsp[(2) - (4)].module);
4483 }
4484 break;
4485
4486 case 202:
4487 #line 1908 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4488 {
4489 (yyval.module) = (yyvsp[(1) - (2)].module);
4490
4491 switch ((yyvsp[(2) - (2)].module).token)
4492 {
4493 case TK_DOCSTRING: (yyval.module).docstring = (yyvsp[(2) - (2)].module).docstring; break;
4494 }
4495 }
4496 break;
4497
4498 case 203:
4499 #line 1918 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4500 {
4501 (yyval.module).token = TK_IF;
4502 }
4503 break;
4504
4505 case 204:
4506 #line 1921 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4507 {
4508 (yyval.module).token = TK_END;
4509 }
4510 break;
4511
4512 case 205:
4513 #line 1924 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4514 {
4515 (yyval.module).token = TK_AUTOPYNAME;
4516 }
4517 break;
4518
4519 case 206:
4520 #line 1927 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4521 {
4522 if (notSkipping())
4523 {
4524 (yyval.module).token = TK_DOCSTRING;
4525 (yyval.module).docstring = (yyvsp[(1) - (1)].docstr);
4526 }
4527 else
4528 {
4529 (yyval.module).token = 0;
4530 (yyval.module).docstring = NULL;
4531 }
4532 }
4533 break;
4534
4535 case 208:
4536 #line 1942 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4537 {
4538 /*
4539 * The grammar design is a bit broken and this is the easiest way
4540 * to allow periods in names.
4541 */
4542
4543 char *cp;
4544
4545 for (cp = (yyvsp[(1) - (1)].text); *cp != '\0'; ++cp)
4546 if (*cp != '.' && *cp != '_' && !isalnum(*cp))
4547 yyerror("Invalid character in name");
4548
4549 (yyval.text) = (yyvsp[(1) - (1)].text);
4550 }
4551 break;
4552
4553 case 209:
4554 #line 1958 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4555 {
4556 (yyval.number) = -1;
4557 }
4558 break;
4559
4560 case 211:
4561 #line 1964 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4562 {
4563 if ((yyvsp[(2) - (2)].include).name == NULL)
4564 yyerror("%Include must have a 'name' argument");
4565
4566 if (notSkipping())
4567 parseFile(NULL, (yyvsp[(2) - (2)].include).name, NULL, (yyvsp[(2) - (2)].include).optional);
4568 }
4569 break;
4570
4571 case 212:
4572 #line 1973 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4573 {
4574 resetLexerState();
4575
4576 (yyval.include).name = (yyvsp[(1) - (1)].text);
4577 (yyval.include).optional = FALSE;
4578 }
4579 break;
4580
4581 case 213:
4582 #line 1979 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4583 {
4584 (yyval.include) = (yyvsp[(2) - (3)].include);
4585 }
4586 break;
4587
4588 case 215:
4589 #line 1985 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4590 {
4591 (yyval.include) = (yyvsp[(1) - (3)].include);
4592
4593 switch ((yyvsp[(3) - (3)].include).token)
4594 {
4595 case TK_NAME: (yyval.include).name = (yyvsp[(3) - (3)].include).name; break;
4596 case TK_OPTIONAL: (yyval.include).optional = (yyvsp[(3) - (3)].include).optional; break;
4597 }
4598 }
4599 break;
4600
4601 case 216:
4602 #line 1996 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4603 {
4604 (yyval.include).token = TK_NAME;
4605
4606 (yyval.include).name = (yyvsp[(3) - (3)].text);
4607 (yyval.include).optional = FALSE;
4608 }
4609 break;
4610
4611 case 217:
4612 #line 2002 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4613 {
4614 (yyval.include).token = TK_OPTIONAL;
4615
4616 (yyval.include).name = NULL;
4617 (yyval.include).optional = (yyvsp[(3) - (3)].boolean);
4618 }
4619 break;
4620
4621 case 218:
4622 #line 2010 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4623 {
4624 if (notSkipping())
4625 newImport((yyvsp[(2) - (2)].import).name);
4626 }
4627 break;
4628
4629 case 219:
4630 #line 2016 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4631 {
4632 resetLexerState();
4633
4634 (yyval.import).name = (yyvsp[(1) - (1)].text);
4635 }
4636 break;
4637
4638 case 220:
4639 #line 2021 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4640 {
4641 (yyval.import) = (yyvsp[(2) - (3)].import);
4642 }
4643 break;
4644
4645 case 222:
4646 #line 2027 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4647 {
4648 (yyval.import) = (yyvsp[(1) - (3)].import);
4649
4650 switch ((yyvsp[(3) - (3)].import).token)
4651 {
4652 case TK_NAME: (yyval.import).name = (yyvsp[(3) - (3)].import).name; break;
4653 }
4654 }
4655 break;
4656
4657 case 223:
4658 #line 2037 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4659 {
4660 (yyval.import).token = TK_NAME;
4661
4662 (yyval.import).name = (yyvsp[(3) - (3)].text);
4663 }
4664 break;
4665
4666 case 224:
4667 #line 2044 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4668 {
4669 if (notSkipping())
4670 appendCodeBlock(¤tModule->copying, (yyvsp[(2) - (2)].codeb));
4671 }
4672 break;
4673
4674 case 225:
4675 #line 2050 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4676 {
4677 if (notSkipping())
4678 appendCodeBlock(¤tSpec->exphdrcode, (yyvsp[(2) - (2)].codeb));
4679 }
4680 break;
4681
4682 case 226:
4683 #line 2056 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4684 {
4685 if (notSkipping())
4686 appendCodeBlock(¤tModule->hdrcode, (yyvsp[(2) - (2)].codeb));
4687 }
4688 break;
4689
4690 case 227:
4691 #line 2062 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4692 {
4693 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4694 }
4695 break;
4696
4697 case 228:
4698 #line 2067 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4699 {
4700 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4701 }
4702 break;
4703
4704 case 229:
4705 #line 2072 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4706 {
4707 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4708 }
4709 break;
4710
4711 case 230:
4712 #line 2077 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4713 {
4714 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4715 }
4716 break;
4717
4718 case 231:
4719 #line 2082 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4720 {
4721 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4722 }
4723 break;
4724
4725 case 232:
4726 #line 2087 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4727 {
4728 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4729 }
4730 break;
4731
4732 case 233:
4733 #line 2092 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4734 {
4735 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4736 }
4737 break;
4738
4739 case 234:
4740 #line 2097 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4741 {
4742 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4743 }
4744 break;
4745
4746 case 235:
4747 #line 2102 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4748 {
4749 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4750 }
4751 break;
4752
4753 case 236:
4754 #line 2107 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4755 {
4756 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4757 }
4758 break;
4759
4760 case 237:
4761 #line 2112 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4762 {
4763 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4764 }
4765 break;
4766
4767 case 238:
4768 #line 2117 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4769 {
4770 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4771 }
4772 break;
4773
4774 case 239:
4775 #line 2122 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4776 {
4777 if (notSkipping())
4778 appendCodeBlock(¤tModule->cppcode, (yyvsp[(2) - (2)].codeb));
4779 }
4780 break;
4781
4782 case 240:
4783 #line 2128 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4784 {
4785 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4786 }
4787 break;
4788
4789 case 241:
4790 #line 2133 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4791 {
4792 if (notSkipping())
4793 appendCodeBlock(¤tModule->preinitcode, (yyvsp[(2) - (2)].codeb));
4794 }
4795 break;
4796
4797 case 242:
4798 #line 2139 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4799 {
4800 if (notSkipping())
4801 appendCodeBlock(¤tModule->initcode, (yyvsp[(2) - (2)].codeb));
4802 }
4803 break;
4804
4805 case 243:
4806 #line 2145 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4807 {
4808 if (notSkipping())
4809 appendCodeBlock(¤tModule->postinitcode, (yyvsp[(2) - (2)].codeb));
4810 }
4811 break;
4812
4813 case 244:
4814 #line 2151 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4815 {
4816 if (notSkipping())
4817 appendCodeBlock(¤tModule->unitcode, (yyvsp[(2) - (2)].codeb));
4818 }
4819 break;
4820
4821 case 245:
4822 #line 2157 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4823 {
4824 if (notSkipping())
4825 appendCodeBlock(¤tModule->unitpostinccode, (yyvsp[(2) - (2)].codeb));
4826 }
4827 break;
4828
4829 case 246:
4830 #line 2163 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4831 {
4832 if (notSkipping() && !inMainModule())
4833 appendCodeBlock(¤tSpec->exptypehintcode, (yyvsp[(2) - (2)].codeb));
4834 }
4835 break;
4836
4837 case 247:
4838 #line 2169 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4839 {
4840 if (notSkipping())
4841 appendCodeBlock(¤tModule->typehintcode, (yyvsp[(2) - (2)].codeb));
4842 }
4843 break;
4844
4845 case 248:
4846 #line 2175 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4847 {
4848 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
4849 }
4850 break;
4851
4852 case 249:
4853 #line 2180 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4854 {
4855 if (notSkipping())
4856 addAutoPyName(currentModule, (yyvsp[(2) - (2)].autopyname).remove_leading);
4857 }
4858 break;
4859
4860 case 250:
4861 #line 2186 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4862 {
4863 (yyval.autopyname) = (yyvsp[(2) - (3)].autopyname);
4864 }
4865 break;
4866
4867 case 252:
4868 #line 2192 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4869 {
4870 (yyval.autopyname) = (yyvsp[(1) - (3)].autopyname);
4871
4872 switch ((yyvsp[(3) - (3)].autopyname).token)
4873 {
4874 case TK_REMOVELEADING: (yyval.autopyname).remove_leading = (yyvsp[(3) - (3)].autopyname).remove_leading; break;
4875 }
4876 }
4877 break;
4878
4879 case 253:
4880 #line 2202 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4881 {
4882 (yyval.autopyname).token = TK_REMOVELEADING;
4883
4884 (yyval.autopyname).remove_leading = (yyvsp[(3) - (3)].text);
4885 }
4886 break;
4887
4888 case 254:
4889 #line 2209 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4890 {
4891 (yyval.docstr) = sipMalloc(sizeof(docstringDef));
4892
4893 (yyval.docstr)->signature = (yyvsp[(2) - (3)].docstring).signature;
4894 (yyval.docstr)->text = (yyvsp[(3) - (3)].codeb)->frag;
4895 free((yyvsp[(3) - (3)].codeb));
4896
4897 /* Format the docstring. */
4898 if ((yyvsp[(2) - (3)].docstring).format == deindented)
4899 {
4900 const char *cp;
4901 char *dp;
4902 int min_indent, indent, skipping;
4903
4904 /* Find the common indent. */
4905 min_indent = -1;
4906 indent = 0;
4907 skipping = FALSE;
4908
4909 for (cp = (yyval.docstr)->text; *cp != '\0'; ++cp)
4910 {
4911 if (skipping)
4912 {
4913 /*
4914 * We have handled the indent and are just looking for
4915 * the end of the line.
4916 */
4917 if (*cp == '\n')
4918 skipping = FALSE;
4919 }
4920 else
4921 {
4922 if (*cp == ' ')
4923 {
4924 ++indent;
4925 }
4926 else if (*cp != '\n')
4927 {
4928 if (min_indent < 0 || min_indent > indent)
4929 min_indent = indent;
4930
4931 /* Ignore the remaining characters of the line. */
4932 skipping = TRUE;
4933 }
4934 }
4935 }
4936
4937 /* In case the last line doesn't have a trailing newline. */
4938 if (min_indent < 0 || min_indent > indent)
4939 min_indent = indent;
4940
4941 /*
4942 * Go through the text again removing the common indentation.
4943 */
4944 cp = dp = (yyval.docstr)->text;
4945
4946 while (*cp != '\0')
4947 {
4948 const char *start = cp;
4949 int non_blank = FALSE;
4950
4951 /* Find the end of the line. */
4952 while (*cp != '\n' && *cp != '\0')
4953 if (*cp++ != ' ')
4954 non_blank = TRUE;
4955
4956 /* Find where we are copying from. */
4957 if (non_blank)
4958 {
4959 start += min_indent;
4960
4961 while (*start != '\n' && *start != '\0')
4962 *dp++ = *start++;
4963 }
4964
4965 if (*cp == '\n')
4966 *dp++ = *cp++;
4967 }
4968
4969 *dp = '\0';
4970 }
4971 }
4972 break;
4973
4974 case 255:
4975 #line 2293 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4976 {
4977 (yyval.docstring).format = currentModule->defdocstringfmt;
4978 (yyval.docstring).signature = currentModule->defdocstringsig;
4979 }
4980 break;
4981
4982 case 256:
4983 #line 2297 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4984 {
4985 resetLexerState();
4986
4987 (yyval.docstring).format = convertFormat((yyvsp[(1) - (1)].text));
4988 (yyval.docstring).signature = currentModule->defdocstringsig;
4989 }
4990 break;
4991
4992 case 257:
4993 #line 2303 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
4994 {
4995 (yyval.docstring) = (yyvsp[(2) - (3)].docstring);
4996 }
4997 break;
4998
4999 case 259:
5000 #line 2309 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5001 {
5002 (yyval.docstring) = (yyvsp[(1) - (3)].docstring);
5003
5004 switch ((yyvsp[(3) - (3)].docstring).token)
5005 {
5006 case TK_FORMAT: (yyval.docstring).format = (yyvsp[(3) - (3)].docstring).format; break;
5007 case TK_SIGNATURE: (yyval.docstring).signature = (yyvsp[(3) - (3)].docstring).signature; break;
5008 }
5009 }
5010 break;
5011
5012 case 260:
5013 #line 2320 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5014 {
5015 (yyval.docstring).token = TK_FORMAT;
5016
5017 (yyval.docstring).format = convertFormat((yyvsp[(3) - (3)].text));
5018 (yyval.docstring).signature = currentModule->defdocstringsig;
5019 }
5020 break;
5021
5022 case 261:
5023 #line 2326 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5024 {
5025 (yyval.docstring).token = TK_SIGNATURE;
5026
5027 (yyval.docstring).format = currentModule->defdocstringfmt;
5028 (yyval.docstring).signature = convertSignature((yyvsp[(3) - (3)].text));
5029 }
5030 break;
5031
5032 case 262:
5033 #line 2334 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5034 {
5035 (yyval.docstr) = NULL;
5036 }
5037 break;
5038
5039 case 264:
5040 #line 2340 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5041 {
5042 if ((yyvsp[(2) - (3)].extract).id == NULL)
5043 yyerror("%Extract must have an 'id' argument");
5044
5045 if (notSkipping())
5046 addExtractPart(currentSpec, (yyvsp[(2) - (3)].extract).id, (yyvsp[(2) - (3)].extract).order, (yyvsp[(3) - (3)].codeb));
5047 }
5048 break;
5049
5050 case 265:
5051 #line 2349 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5052 {
5053 resetLexerState();
5054
5055 (yyval.extract).id = (yyvsp[(1) - (1)].text);
5056 (yyval.extract).order = -1;
5057 }
5058 break;
5059
5060 case 266:
5061 #line 2355 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5062 {
5063 (yyval.extract) = (yyvsp[(2) - (3)].extract);
5064 }
5065 break;
5066
5067 case 268:
5068 #line 2361 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5069 {
5070 (yyval.extract) = (yyvsp[(1) - (3)].extract);
5071
5072 switch ((yyvsp[(3) - (3)].extract).token)
5073 {
5074 case TK_ID: (yyval.extract).id = (yyvsp[(3) - (3)].extract).id; break;
5075 case TK_ORDER: (yyval.extract).order = (yyvsp[(3) - (3)].extract).order; break;
5076 }
5077 }
5078 break;
5079
5080 case 269:
5081 #line 2372 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5082 {
5083 (yyval.extract).token = TK_ID;
5084
5085 (yyval.extract).id = (yyvsp[(3) - (3)].text);
5086 (yyval.extract).order = -1;
5087 }
5088 break;
5089
5090 case 270:
5091 #line 2378 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5092 {
5093 (yyval.extract).token = TK_ORDER;
5094
5095 if ((yyvsp[(3) - (3)].number) < 0)
5096 yyerror("The 'order' of an %Extract directive must not be negative");
5097
5098 (yyval.extract).id = NULL;
5099 (yyval.extract).order = (yyvsp[(3) - (3)].number);
5100 }
5101 break;
5102
5103 case 273:
5104 #line 2393 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5105 {
5106 (yyval.codeb) = (yyvsp[(1) - (2)].codeb);
5107
5108 append(&(yyval.codeb)->frag, (yyvsp[(2) - (2)].codeb)->frag);
5109
5110 free((yyvsp[(2) - (2)].codeb)->frag);
5111 free((yyvsp[(2) - (2)].codeb));
5112 }
5113 break;
5114
5115 case 274:
5116 #line 2403 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5117 {
5118 if (notSkipping())
5119 {
5120 const char *annos[] = {
5121 "NoScope",
5122 "NoTypeHint",
5123 "PyName",
5124 NULL
5125 };
5126
5127 checkAnnos(&(yyvsp[(4) - (4)].optflags), annos);
5128
5129 if (sectionFlags != 0 && (sectionFlags & ~(SECT_IS_PUBLIC | SECT_IS_PROT)) != 0)
5130 yyerror("Class enums must be in the public or protected sections");
5131
5132 if (currentSpec->genc && (yyvsp[(2) - (4)].boolean))
5133 yyerror("Scoped enums not allowed in a C module");
5134
5135 currentEnum = newEnum(currentSpec, currentModule,
5136 currentMappedType, (yyvsp[(3) - (4)].text), &(yyvsp[(4) - (4)].optflags), sectionFlags, (yyvsp[(2) - (4)].boolean));
5137 }
5138 }
5139 break;
5140
5141 case 276:
5142 #line 2427 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5143 {
5144 (yyval.boolean) = FALSE;
5145 }
5146 break;
5147
5148 case 277:
5149 #line 2430 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5150 {
5151 (yyval.boolean) = TRUE;
5152 }
5153 break;
5154
5155 case 278:
5156 #line 2433 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5157 {
5158 (yyval.boolean) = TRUE;
5159 }
5160 break;
5161
5162 case 279:
5163 #line 2438 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5164 {
5165 (yyval.text) = NULL;
5166 }
5167 break;
5168
5169 case 280:
5170 #line 2441 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5171 {
5172 (yyval.text) = (yyvsp[(1) - (1)].text);
5173 }
5174 break;
5175
5176 case 287:
5177 #line 2456 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5178 {
5179 if (notSkipping())
5180 {
5181 const char *annos[] = {
5182 "NoTypeHint",
5183 "PyName",
5184 NULL
5185 };
5186
5187 enumMemberDef *emd, **tail;
5188
5189 checkAnnos(&(yyvsp[(3) - (4)].optflags), annos);
5190
5191 /* Note that we don't use the assigned value. */
5192 emd = sipMalloc(sizeof (enumMemberDef));
5193
5194 emd->pyname = cacheName(currentSpec,
5195 getPythonName(currentModule, &(yyvsp[(3) - (4)].optflags), (yyvsp[(1) - (4)].text)));
5196 emd->cname = (yyvsp[(1) - (4)].text);
5197 emd->no_typehint = getNoTypeHint(&(yyvsp[(3) - (4)].optflags));
5198 emd->ed = currentEnum;
5199 emd->platforms = currentPlatforms;
5200 emd->next = NULL;
5201
5202 /*
5203 * Note that we don't check that members of scoped enums are
5204 * unique.
5205 */
5206 if (!isScopedEnum(currentEnum))
5207 checkAttributes(currentSpec, currentModule, emd->ed->ecd,
5208 emd->ed->emtd, emd->pyname->text, FALSE);
5209
5210 /* Append to preserve the order. */
5211 for (tail = ¤tEnum->members; *tail != NULL; tail = &(*tail)->next)
5212 ;
5213
5214 *tail = emd;
5215
5216 if (inMainModule())
5217 setIsUsedName(emd->pyname);
5218 }
5219 }
5220 break;
5221
5222 case 292:
5223 #line 2508 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5224 {
5225 (yyval.valp) = NULL;
5226 }
5227 break;
5228
5229 case 293:
5230 #line 2511 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5231 {
5232 (yyval.valp) = (yyvsp[(2) - (2)].valp);
5233 }
5234 break;
5235
5236 case 295:
5237 #line 2517 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5238 {
5239 valueDef *vd;
5240
5241 if ((yyvsp[(1) - (3)].valp) -> vtype == string_value || (yyvsp[(3) - (3)].valp) -> vtype == string_value)
5242 yyerror("Invalid binary operator for string");
5243
5244 /* Find the last value in the existing expression. */
5245
5246 for (vd = (yyvsp[(1) - (3)].valp); vd -> next != NULL; vd = vd -> next)
5247 ;
5248
5249 vd -> vbinop = (yyvsp[(2) - (3)].qchar);
5250 vd -> next = (yyvsp[(3) - (3)].valp);
5251
5252 (yyval.valp) = (yyvsp[(1) - (3)].valp);
5253 }
5254 break;
5255
5256 case 296:
5257 #line 2535 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5258 {
5259 (yyval.qchar) = '-';
5260 }
5261 break;
5262
5263 case 297:
5264 #line 2538 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5265 {
5266 (yyval.qchar) = '+';
5267 }
5268 break;
5269
5270 case 298:
5271 #line 2541 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5272 {
5273 (yyval.qchar) = '*';
5274 }
5275 break;
5276
5277 case 299:
5278 #line 2544 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5279 {
5280 (yyval.qchar) = '/';
5281 }
5282 break;
5283
5284 case 300:
5285 #line 2547 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5286 {
5287 (yyval.qchar) = '&';
5288 }
5289 break;
5290
5291 case 301:
5292 #line 2550 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5293 {
5294 (yyval.qchar) = '|';
5295 }
5296 break;
5297
5298 case 302:
5299 #line 2555 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5300 {
5301 (yyval.qchar) = '\0';
5302 }
5303 break;
5304
5305 case 303:
5306 #line 2558 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5307 {
5308 (yyval.qchar) = '!';
5309 }
5310 break;
5311
5312 case 304:
5313 #line 2561 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5314 {
5315 (yyval.qchar) = '~';
5316 }
5317 break;
5318
5319 case 305:
5320 #line 2564 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5321 {
5322 (yyval.qchar) = '-';
5323 }
5324 break;
5325
5326 case 306:
5327 #line 2567 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5328 {
5329 (yyval.qchar) = '+';
5330 }
5331 break;
5332
5333 case 307:
5334 #line 2570 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5335 {
5336 (yyval.qchar) = '*';
5337 }
5338 break;
5339
5340 case 308:
5341 #line 2573 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5342 {
5343 (yyval.qchar) = '&';
5344 }
5345 break;
5346
5347 case 309:
5348 #line 2578 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5349 {
5350 if ((yyvsp[(2) - (3)].qchar) != '\0' && (yyvsp[(3) - (3)].value).vtype == string_value)
5351 yyerror("Invalid unary operator for string");
5352
5353 /* Convert the value to a simple expression on the heap. */
5354 (yyval.valp) = sipMalloc(sizeof (valueDef));
5355
5356 *(yyval.valp) = (yyvsp[(3) - (3)].value);
5357 (yyval.valp)->vunop = (yyvsp[(2) - (3)].qchar);
5358 (yyval.valp)->vbinop = '\0';
5359 (yyval.valp)->cast = (yyvsp[(1) - (3)].scpvalp);
5360 (yyval.valp)->next = NULL;
5361 }
5362 break;
5363
5364 case 310:
5365 #line 2593 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5366 {
5367 (yyval.scpvalp) = NULL;
5368 }
5369 break;
5370
5371 case 311:
5372 #line 2596 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5373 {
5374 (yyval.scpvalp) = (yyvsp[(2) - (3)].scpvalp);
5375 }
5376 break;
5377
5378 case 312:
5379 #line 2601 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5380 {
5381 if (currentSpec->genc)
5382 yyerror("Scoped names are not allowed in a C module");
5383
5384 (yyval.scpvalp) = scopeScopedName(NULL, (yyvsp[(2) - (2)].scpvalp));
5385 }
5386 break;
5387
5388 case 315:
5389 #line 2611 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5390 {
5391 if (currentSpec->genc)
5392 yyerror("Scoped names are not allowed in a C module");
5393
5394 appendScopedName(&(yyvsp[(1) - (3)].scpvalp), (yyvsp[(3) - (3)].scpvalp));
5395 }
5396 break;
5397
5398 case 316:
5399 #line 2619 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5400 {
5401 (yyval.scpvalp) = text2scopePart((yyvsp[(1) - (1)].text));
5402 }
5403 break;
5404
5405 case 317:
5406 #line 2624 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5407 {
5408 (yyval.boolean) = TRUE;
5409 }
5410 break;
5411
5412 case 318:
5413 #line 2627 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5414 {
5415 (yyval.boolean) = FALSE;
5416 }
5417 break;
5418
5419 case 319:
5420 #line 2632 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5421 {
5422 /*
5423 * We let the C++ compiler decide if the value is a valid one - no
5424 * point in building a full C++ parser here.
5425 */
5426
5427 (yyval.value).vtype = scoped_value;
5428 (yyval.value).u.vscp = (yyvsp[(1) - (1)].scpvalp);
5429 }
5430 break;
5431
5432 case 320:
5433 #line 2641 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5434 {
5435 fcallDef *fcd;
5436
5437 fcd = sipMalloc(sizeof (fcallDef));
5438 *fcd = (yyvsp[(3) - (4)].fcall);
5439 fcd -> type = (yyvsp[(1) - (4)].memArg);
5440
5441 (yyval.value).vtype = fcall_value;
5442 (yyval.value).u.fcd = fcd;
5443 }
5444 break;
5445
5446 case 321:
5447 #line 2651 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5448 {
5449 (yyval.value).vtype = empty_value;
5450 }
5451 break;
5452
5453 case 322:
5454 #line 2654 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5455 {
5456 (yyval.value).vtype = real_value;
5457 (yyval.value).u.vreal = (yyvsp[(1) - (1)].real);
5458 }
5459 break;
5460
5461 case 323:
5462 #line 2658 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5463 {
5464 (yyval.value).vtype = numeric_value;
5465 (yyval.value).u.vnum = (yyvsp[(1) - (1)].number);
5466 }
5467 break;
5468
5469 case 324:
5470 #line 2662 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5471 {
5472 (yyval.value).vtype = numeric_value;
5473 (yyval.value).u.vnum = (yyvsp[(1) - (1)].boolean);
5474 }
5475 break;
5476
5477 case 325:
5478 #line 2666 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5479 {
5480 (yyval.value).vtype = numeric_value;
5481 (yyval.value).u.vnum = 0;
5482 }
5483 break;
5484
5485 case 326:
5486 #line 2670 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5487 {
5488 (yyval.value).vtype = string_value;
5489 (yyval.value).u.vstr = (yyvsp[(1) - (1)].text);
5490 }
5491 break;
5492
5493 case 327:
5494 #line 2674 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5495 {
5496 (yyval.value).vtype = qchar_value;
5497 (yyval.value).u.vqchar = (yyvsp[(1) - (1)].qchar);
5498 }
5499 break;
5500
5501 case 328:
5502 #line 2680 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5503 {
5504 /* No values. */
5505
5506 (yyval.fcall).nrArgs = 0;
5507 }
5508 break;
5509
5510 case 329:
5511 #line 2685 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5512 {
5513 /* The single or first expression. */
5514
5515 (yyval.fcall).args[0] = (yyvsp[(1) - (1)].valp);
5516 (yyval.fcall).nrArgs = 1;
5517 }
5518 break;
5519
5520 case 330:
5521 #line 2691 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5522 {
5523 /* Check that it wasn't ...(,expression...). */
5524
5525 if ((yyval.fcall).nrArgs == 0)
5526 yyerror("First argument to function call is missing");
5527
5528 /* Check there is room. */
5529
5530 if ((yyvsp[(1) - (3)].fcall).nrArgs == MAX_NR_ARGS)
5531 yyerror("Internal error - increase the value of MAX_NR_ARGS");
5532
5533 (yyval.fcall) = (yyvsp[(1) - (3)].fcall);
5534
5535 (yyval.fcall).args[(yyval.fcall).nrArgs] = (yyvsp[(3) - (3)].valp);
5536 (yyval.fcall).nrArgs++;
5537 }
5538 break;
5539
5540 case 331:
5541 #line 2709 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5542 {
5543 if (notSkipping())
5544 {
5545 const char *annos[] = {
5546 "Capsule",
5547 "Encoding",
5548 "NoTypeName",
5549 "PyInt",
5550 "PyName",
5551 "TypeHint",
5552 "TypeHintIn",
5553 "TypeHintOut",
5554 NULL
5555 };
5556
5557 checkAnnos(&(yyvsp[(4) - (6)].optflags), annos);
5558
5559 applyTypeFlags(currentModule, &(yyvsp[(2) - (6)].memArg), &(yyvsp[(4) - (6)].optflags));
5560 newTypedef(currentSpec, currentModule, (yyvsp[(3) - (6)].text), &(yyvsp[(2) - (6)].memArg), &(yyvsp[(4) - (6)].optflags), (yyvsp[(6) - (6)].docstr));
5561 }
5562 }
5563 break;
5564
5565 case 332:
5566 #line 2730 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5567 {
5568 if (notSkipping())
5569 {
5570 const char *annos[] = {
5571 "Encoding",
5572 "NoTypeName",
5573 "PyInt",
5574 "PyName",
5575 "TypeHint",
5576 "TypeHintIn",
5577 "TypeHintOut",
5578 NULL
5579 };
5580
5581 signatureDef *sig;
5582 argDef ftype;
5583
5584 checkAnnos(&(yyvsp[(10) - (12)].optflags), annos);
5585
5586 applyTypeFlags(currentModule, &(yyvsp[(2) - (12)].memArg), &(yyvsp[(10) - (12)].optflags));
5587
5588 memset(&ftype, 0, sizeof (argDef));
5589
5590 /* Create the full signature on the heap. */
5591 sig = sipMalloc(sizeof (signatureDef));
5592 *sig = (yyvsp[(8) - (12)].signature);
5593 sig->result = (yyvsp[(2) - (12)].memArg);
5594
5595 /* Create the full type. */
5596 ftype.atype = function_type;
5597 ftype.nrderefs = 1;
5598 ftype.u.sa = sig;
5599
5600 newTypedef(currentSpec, currentModule, (yyvsp[(5) - (12)].text), &ftype, &(yyvsp[(10) - (12)].optflags), (yyvsp[(12) - (12)].docstr));
5601 }
5602 }
5603 break;
5604
5605 case 333:
5606 #line 2768 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5607 {
5608 if (currentSpec -> genc && (yyvsp[(2) - (2)].scpvalp)->next != NULL)
5609 yyerror("Namespaces not allowed in a C module");
5610
5611 if (notSkipping())
5612 currentSupers = NULL;
5613 }
5614 break;
5615
5616 case 334:
5617 #line 2774 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5618 {
5619 if (notSkipping())
5620 {
5621 const char *annos[] = {
5622 "Abstract",
5623 "AllowNone",
5624 "API",
5625 "DelayDtor",
5626 "Deprecated",
5627 "ExportDerived",
5628 "External",
5629 "FileExtension",
5630 "Metatype",
5631 "Mixin",
5632 "NoDefaultCtors",
5633 "NoTypeHint",
5634 "PyName",
5635 "PyQtFlags",
5636 "PyQtFlagsEnums",
5637 "PyQtInterface",
5638 "PyQtNoQMetaObject",
5639 "Supertype",
5640 "TypeHint",
5641 "TypeHintIn",
5642 "TypeHintOut",
5643 "TypeHintValue",
5644 "VirtualErrorHandler",
5645 NULL
5646 };
5647
5648 checkAnnos(&(yyvsp[(5) - (5)].optflags), annos);
5649
5650 if (currentSpec->genc && currentSupers != NULL)
5651 yyerror("Super-classes not allowed in a C module struct");
5652
5653 defineClass((yyvsp[(2) - (5)].scpvalp), currentSupers, &(yyvsp[(5) - (5)].optflags));
5654 sectionFlags = SECT_IS_PUBLIC;
5655 }
5656 }
5657 break;
5658
5659 case 335:
5660 #line 2812 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5661 {
5662 if (notSkipping())
5663 completeClass((yyvsp[(2) - (8)].scpvalp), &(yyvsp[(5) - (8)].optflags), (yyvsp[(7) - (8)].boolean));
5664 }
5665 break;
5666
5667 case 336:
5668 #line 2818 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5669 {currentIsTemplate = TRUE;}
5670 break;
5671
5672 case 337:
5673 #line 2818 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5674 {
5675 if (currentSpec->genc)
5676 yyerror("Class templates not allowed in a C module");
5677
5678 if (notSkipping())
5679 {
5680 classTmplDef *tcd;
5681
5682 /*
5683 * Make sure there is room for the extra class name argument.
5684 */
5685 if ((yyvsp[(1) - (3)].signature).nrArgs == MAX_NR_ARGS)
5686 yyerror("Internal error - increase the value of MAX_NR_ARGS");
5687
5688 tcd = sipMalloc(sizeof (classTmplDef));
5689 tcd->sig = (yyvsp[(1) - (3)].signature);
5690 tcd->cd = (yyvsp[(3) - (3)].klass);
5691 tcd->next = currentSpec->classtemplates;
5692
5693 currentSpec->classtemplates = tcd;
5694 }
5695
5696 currentIsTemplate = FALSE;
5697 }
5698 break;
5699
5700 case 338:
5701 #line 2844 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5702 {
5703 (yyval.signature) = (yyvsp[(3) - (4)].signature);
5704 }
5705 break;
5706
5707 case 339:
5708 #line 2849 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5709 {
5710 if (currentSpec->genc)
5711 yyerror("Class definition not allowed in a C module");
5712
5713 if (notSkipping())
5714 currentSupers = NULL;
5715 }
5716 break;
5717
5718 case 340:
5719 #line 2855 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5720 {
5721 if (notSkipping())
5722 {
5723 const char *annos[] = {
5724 "Abstract",
5725 "AllowNone",
5726 "API",
5727 "DelayDtor",
5728 "Deprecated",
5729 "ExportDerived",
5730 "External",
5731 "FileExtension",
5732 "Metatype",
5733 "Mixin",
5734 "NoDefaultCtors",
5735 "PyName",
5736 "PyQtFlags",
5737 "PyQtFlagsEnums",
5738 "PyQtInterface",
5739 "PyQtNoQMetaObject",
5740 "Supertype",
5741 "TypeHint",
5742 "TypeHintIn",
5743 "TypeHintOut",
5744 "TypeHintValue",
5745 "VirtualErrorHandler",
5746 NULL
5747 };
5748
5749 checkAnnos(&(yyvsp[(5) - (5)].optflags), annos);
5750
5751 defineClass((yyvsp[(2) - (5)].scpvalp), currentSupers, &(yyvsp[(5) - (5)].optflags));
5752 sectionFlags = SECT_IS_PRIVATE;
5753 }
5754 }
5755 break;
5756
5757 case 341:
5758 #line 2889 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5759 {
5760 if (notSkipping())
5761 (yyval.klass) = completeClass((yyvsp[(2) - (8)].scpvalp), &(yyvsp[(5) - (8)].optflags), (yyvsp[(7) - (8)].boolean));
5762 }
5763 break;
5764
5765 case 346:
5766 #line 2903 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5767 {
5768 if (notSkipping() && (yyvsp[(1) - (2)].token) == TK_PUBLIC)
5769 {
5770 argDef ad;
5771 classDef *super;
5772 scopedNameDef *snd = (yyvsp[(2) - (2)].scpvalp);
5773
5774 /*
5775 * This is a hack to allow typedef'ed classes to be used before
5776 * we have resolved the typedef definitions. Unlike elsewhere,
5777 * we require that the typedef is defined before being used.
5778 */
5779 for (;;)
5780 {
5781 ad.atype = no_type;
5782 ad.argflags = 0;
5783 ad.nrderefs = 0;
5784 ad.original_type = NULL;
5785
5786 searchTypedefs(currentSpec, snd, &ad);
5787
5788 if (ad.atype != defined_type)
5789 break;
5790
5791 if (ad.nrderefs != 0 || isConstArg(&ad) || isReference(&ad))
5792 break;
5793
5794 snd = ad.u.snd;
5795 }
5796
5797 if (ad.atype != no_type)
5798 yyerror("Super-class list contains an invalid type");
5799
5800 /*
5801 * This is a bug because we should look in the local scope
5802 * rather than assume it is in the global scope.
5803 */
5804 if (snd->name[0] != '\0')
5805 snd = scopeScopedName(NULL, snd);
5806
5807 /*
5808 * Note that passing NULL as the API is a bug. Instead we
5809 * should pass the API of the sub-class being defined,
5810 * otherwise we cannot create sub-classes of versioned classes.
5811 */
5812 super = findClass(currentSpec, class_iface, NULL, snd,
5813 currentIsTemplate);
5814 appendToClassList(¤tSupers, super);
5815 }
5816 }
5817 break;
5818
5819 case 347:
5820 #line 2955 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5821 {
5822 (yyval.token) = TK_PUBLIC;
5823 }
5824 break;
5825
5826 case 348:
5827 #line 2958 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5828 {
5829 (yyval.token) = TK_PUBLIC;
5830 }
5831 break;
5832
5833 case 349:
5834 #line 2961 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5835 {
5836 (yyval.token) = TK_PROTECTED;
5837 }
5838 break;
5839
5840 case 350:
5841 #line 2964 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5842 {
5843 (yyval.token) = TK_PRIVATE;
5844 }
5845 break;
5846
5847 case 351:
5848 #line 2969 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5849 {
5850 (yyval.boolean) = FALSE;
5851 }
5852 break;
5853
5854 case 352:
5855 #line 2972 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5856 {
5857 (yyval.boolean) = TRUE;
5858 }
5859 break;
5860
5861 case 366:
5862 #line 2992 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5863 {
5864 if (notSkipping())
5865 {
5866 classDef *scope = currentScope();
5867
5868 if (scope->docstring != NULL)
5869 yyerror("%Docstring already given for class");
5870
5871 scope->docstring = (yyvsp[(1) - (1)].docstr);
5872 }
5873 }
5874 break;
5875
5876 case 367:
5877 #line 3003 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5878 {
5879 if (notSkipping())
5880 appendCodeBlock(¤tScope()->cppcode, (yyvsp[(1) - (1)].codeb));
5881 }
5882 break;
5883
5884 case 368:
5885 #line 3007 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5886 {
5887 if (notSkipping())
5888 appendCodeBlock(¤tScope()->iff->hdrcode, (yyvsp[(1) - (1)].codeb));
5889 }
5890 break;
5891
5892 case 369:
5893 #line 3011 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5894 {
5895 if (notSkipping())
5896 {
5897 classDef *scope = currentScope();
5898
5899 if (scope->travcode != NULL)
5900 yyerror("%GCTraverseCode already given for class");
5901
5902 appendCodeBlock(&scope->travcode, (yyvsp[(1) - (1)].codeb));
5903 }
5904 }
5905 break;
5906
5907 case 370:
5908 #line 3022 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5909 {
5910 if (notSkipping())
5911 {
5912 classDef *scope = currentScope();
5913
5914 if (scope->clearcode != NULL)
5915 yyerror("%GCClearCode already given for class");
5916
5917 appendCodeBlock(&scope->clearcode, (yyvsp[(1) - (1)].codeb));
5918 }
5919 }
5920 break;
5921
5922 case 371:
5923 #line 3033 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5924 {
5925 if (notSkipping())
5926 {
5927 classDef *scope = currentScope();
5928
5929 if (scope->getbufcode != NULL)
5930 yyerror("%BIGetBufferCode already given for class");
5931
5932 appendCodeBlock(&scope->getbufcode, (yyvsp[(1) - (1)].codeb));
5933 }
5934 }
5935 break;
5936
5937 case 372:
5938 #line 3044 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5939 {
5940 if (notSkipping())
5941 {
5942 classDef *scope = currentScope();
5943
5944 if (scope->releasebufcode != NULL)
5945 yyerror("%BIReleaseBufferCode already given for class");
5946
5947 appendCodeBlock(&scope->releasebufcode, (yyvsp[(1) - (1)].codeb));
5948 }
5949 }
5950 break;
5951
5952 case 373:
5953 #line 3055 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5954 {
5955 /* Remove in v6. */
5956 }
5957 break;
5958
5959 case 374:
5960 #line 3058 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5961 {
5962 /* Remove in v6. */
5963 }
5964 break;
5965
5966 case 375:
5967 #line 3061 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5968 {
5969 /* Remove in v6. */
5970 }
5971 break;
5972
5973 case 376:
5974 #line 3064 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5975 {
5976 /* Remove in v6. */
5977 }
5978 break;
5979
5980 case 377:
5981 #line 3067 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5982 {
5983 if (notSkipping())
5984 {
5985 classDef *scope = currentScope();
5986
5987 if (scope->instancecode != NULL)
5988 yyerror("%InstanceCode already given for class");
5989
5990 appendCodeBlock(&scope->instancecode, (yyvsp[(1) - (1)].codeb));
5991 }
5992 }
5993 break;
5994
5995 case 378:
5996 #line 3078 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
5997 {
5998 if (notSkipping())
5999 {
6000 classDef *scope = currentScope();
6001
6002 if (scope->picklecode != NULL)
6003 yyerror("%PickleCode already given for class");
6004
6005 appendCodeBlock(&scope->picklecode, (yyvsp[(1) - (1)].codeb));
6006 }
6007 }
6008 break;
6009
6010 case 379:
6011 #line 3089 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6012 {
6013 if (notSkipping())
6014 {
6015 classDef *scope = currentScope();
6016
6017 if (scope->finalcode != NULL)
6018 yyerror("%FinalisationCode already given for class");
6019
6020 appendCodeBlock(&scope->finalcode, (yyvsp[(1) - (1)].codeb));
6021 }
6022 }
6023 break;
6024
6025 case 380:
6026 #line 3100 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6027 {
6028 if (notSkipping())
6029 {
6030 classDef *scope = currentScope();
6031
6032 if (scope->typehintcode != NULL)
6033 yyerror("%TypeHintCode already given for class");
6034
6035 appendCodeBlock(&scope->typehintcode, (yyvsp[(1) - (1)].codeb));
6036 }
6037 }
6038 break;
6039
6040 case 384:
6041 #line 3114 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6042 {
6043 if (notSkipping())
6044 {
6045 classDef *scope = currentScope();
6046
6047 if (scope->convtosubcode != NULL)
6048 yyerror("Class has more than one %ConvertToSubClassCode directive");
6049
6050 appendCodeBlock(&scope->convtosubcode, (yyvsp[(2) - (2)].codeb));
6051 }
6052 }
6053 break;
6054
6055 case 385:
6056 #line 3125 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6057 {
6058 if (notSkipping())
6059 {
6060 classDef *scope = currentScope();
6061
6062 if (scope->convtocode != NULL)
6063 yyerror("Class has more than one %ConvertToTypeCode directive");
6064
6065 appendCodeBlock(&scope->convtocode, (yyvsp[(2) - (2)].codeb));
6066 }
6067 }
6068 break;
6069
6070 case 386:
6071 #line 3136 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6072 {
6073 if (notSkipping())
6074 {
6075 classDef *scope = currentScope();
6076
6077 if (scope->convfromcode != NULL)
6078 yyerror("Class has more than one %ConvertFromTypeCode directive");
6079
6080 appendCodeBlock(&scope->convfromcode, (yyvsp[(2) - (2)].codeb));
6081 }
6082 }
6083 break;
6084
6085 case 387:
6086 #line 3147 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6087 {
6088 if (currentSpec -> genc)
6089 yyerror("public section not allowed in a C module");
6090
6091 if (notSkipping())
6092 sectionFlags = SECT_IS_PUBLIC | (yyvsp[(2) - (3)].number);
6093 }
6094 break;
6095
6096 case 388:
6097 #line 3154 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6098 {
6099 if (currentSpec -> genc)
6100 yyerror("protected section not allowed in a C module");
6101
6102 if (notSkipping())
6103 sectionFlags = SECT_IS_PROT | (yyvsp[(2) - (3)].number);
6104 }
6105 break;
6106
6107 case 389:
6108 #line 3161 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6109 {
6110 if (currentSpec -> genc)
6111 yyerror("private section not allowed in a C module");
6112
6113 if (notSkipping())
6114 sectionFlags = SECT_IS_PRIVATE | (yyvsp[(2) - (3)].number);
6115 }
6116 break;
6117
6118 case 390:
6119 #line 3168 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6120 {
6121 if (currentSpec -> genc)
6122 yyerror("signals section not allowed in a C module");
6123
6124 if (notSkipping())
6125 sectionFlags = SECT_IS_SIGNAL;
6126 }
6127 break;
6128
6129 case 391:
6130 #line 3177 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6131 {
6132 if ((yyvsp[(2) - (3)].property).name == NULL)
6133 yyerror("A %Property directive must have a 'name' argument");
6134
6135 if ((yyvsp[(2) - (3)].property).get == NULL)
6136 yyerror("A %Property directive must have a 'get' argument");
6137
6138 if (notSkipping())
6139 addProperty(currentSpec, currentModule, currentScope(),
6140 (yyvsp[(2) - (3)].property).name, (yyvsp[(2) - (3)].property).get, (yyvsp[(2) - (3)].property).set, (yyvsp[(3) - (3)].property).docstring);
6141 }
6142 break;
6143
6144 case 392:
6145 #line 3190 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6146 {
6147 (yyval.property) = (yyvsp[(2) - (3)].property);
6148 }
6149 break;
6150
6151 case 394:
6152 #line 3196 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6153 {
6154 (yyval.property) = (yyvsp[(1) - (3)].property);
6155
6156 switch ((yyvsp[(3) - (3)].property).token)
6157 {
6158 case TK_GET: (yyval.property).get = (yyvsp[(3) - (3)].property).get; break;
6159 case TK_NAME: (yyval.property).name = (yyvsp[(3) - (3)].property).name; break;
6160 case TK_SET: (yyval.property).set = (yyvsp[(3) - (3)].property).set; break;
6161 }
6162 }
6163 break;
6164
6165 case 395:
6166 #line 3208 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6167 {
6168 (yyval.property).token = TK_GET;
6169
6170 (yyval.property).get = (yyvsp[(3) - (3)].text);
6171 (yyval.property).name = NULL;
6172 (yyval.property).set = NULL;
6173 }
6174 break;
6175
6176 case 396:
6177 #line 3215 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6178 {
6179 (yyval.property).token = TK_NAME;
6180
6181 (yyval.property).get = NULL;
6182 (yyval.property).name = (yyvsp[(3) - (3)].text);
6183 (yyval.property).set = NULL;
6184 }
6185 break;
6186
6187 case 397:
6188 #line 3222 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6189 {
6190 (yyval.property).token = TK_SET;
6191
6192 (yyval.property).get = NULL;
6193 (yyval.property).name = NULL;
6194 (yyval.property).set = (yyvsp[(3) - (3)].text);
6195 }
6196 break;
6197
6198 case 398:
6199 #line 3231 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6200 {
6201 (yyval.property).token = 0;
6202 (yyval.property).docstring = NULL;
6203 }
6204 break;
6205
6206 case 399:
6207 #line 3235 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6208 {
6209 (yyval.property) = (yyvsp[(2) - (4)].property);
6210 }
6211 break;
6212
6213 case 401:
6214 #line 3241 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6215 {
6216 (yyval.property) = (yyvsp[(1) - (2)].property);
6217
6218 switch ((yyvsp[(2) - (2)].property).token)
6219 {
6220 case TK_DOCSTRING: (yyval.property).docstring = (yyvsp[(2) - (2)].property).docstring; break;
6221 }
6222 }
6223 break;
6224
6225 case 402:
6226 #line 3251 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6227 {
6228 (yyval.property).token = TK_IF;
6229 }
6230 break;
6231
6232 case 403:
6233 #line 3254 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6234 {
6235 (yyval.property).token = TK_END;
6236 }
6237 break;
6238
6239 case 404:
6240 #line 3257 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6241 {
6242 if (notSkipping())
6243 {
6244 (yyval.property).token = TK_DOCSTRING;
6245 (yyval.property).docstring = (yyvsp[(1) - (1)].docstr);
6246 }
6247 else
6248 {
6249 (yyval.property).token = 0;
6250 (yyval.property).docstring = NULL;
6251 }
6252 }
6253 break;
6254
6255 case 407:
6256 #line 3275 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6257 {
6258 (yyval.number) = 0;
6259 }
6260 break;
6261
6262 case 408:
6263 #line 3278 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6264 {
6265 (yyval.number) = SECT_IS_SLOT;
6266 }
6267 break;
6268
6269 case 409:
6270 #line 3284 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6271 {currentIsVirt = TRUE;}
6272 break;
6273
6274 case 412:
6275 #line 3288 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6276 {
6277 /* Note that we allow non-virtual dtors in C modules. */
6278
6279 if (notSkipping())
6280 {
6281 const char *annos[] = {
6282 "HoldGIL",
6283 "ReleaseGIL",
6284 NULL
6285 };
6286
6287 classDef *cd = currentScope();
6288
6289 checkAnnos(&(yyvsp[(7) - (11)].optflags), annos);
6290
6291 if (strcmp(classBaseName(cd),(yyvsp[(2) - (11)].text)) != 0)
6292 yyerror("Destructor doesn't have the same name as its class");
6293
6294 if (isDtor(cd))
6295 yyerror("Destructor has already been defined");
6296
6297 if (currentSpec -> genc && (yyvsp[(9) - (11)].codeb) == NULL)
6298 yyerror("Destructor in C modules must include %MethodCode");
6299
6300
6301 appendCodeBlock(&cd->dealloccode, (yyvsp[(9) - (11)].codeb)); /* premethodcode */
6302 appendCodeBlock(&cd->dealloccode, (yyvsp[(10) - (11)].codeb)); /* methodcode */
6303 appendCodeBlock(&cd->dtorcode, (yyvsp[(11) - (11)].codeb));
6304 cd -> dtorexceptions = (yyvsp[(5) - (11)].throwlist);
6305
6306 /*
6307 * Note that we don't apply the protected/public hack to dtors
6308 * as it (I think) may change the behaviour of the wrapped API.
6309 */
6310 cd->classflags |= sectionFlags;
6311
6312 if ((yyvsp[(6) - (11)].number))
6313 {
6314 if (!currentIsVirt)
6315 yyerror("Abstract destructor must be virtual");
6316
6317 setIsAbstractClass(cd);
6318 }
6319
6320 /*
6321 * The class has a shadow if we have a virtual dtor or some
6322 * dtor code.
6323 */
6324 if (currentIsVirt || (yyvsp[(10) - (11)].codeb) != NULL)
6325 {
6326 if (currentSpec -> genc)
6327 yyerror("Virtual destructor or %VirtualCatcherCode not allowed in a C module");
6328
6329 setNeedsShadow(cd);
6330 }
6331
6332 if (getReleaseGIL(&(yyvsp[(7) - (11)].optflags)))
6333 setIsReleaseGILDtor(cd);
6334 else if (getHoldGIL(&(yyvsp[(7) - (11)].optflags)))
6335 setIsHoldGILDtor(cd);
6336 }
6337
6338 currentIsVirt = FALSE;
6339 }
6340 break;
6341
6342 case 413:
6343 #line 3354 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6344 {currentCtorIsExplicit = TRUE;}
6345 break;
6346
6347 case 416:
6348 #line 3358 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6349 {
6350 /* Note that we allow ctors in C modules. */
6351
6352 if (notSkipping())
6353 {
6354 const char *annos[] = {
6355 "API",
6356 "Default",
6357 "Deprecated",
6358 "HoldGIL",
6359 "KeywordArgs",
6360 "NoDerived",
6361 "NoRaisesPyException",
6362 "NoTypeHint",
6363 "PostHook",
6364 "PreHook",
6365 "RaisesPyException",
6366 "ReleaseGIL",
6367 "Transfer",
6368 NULL
6369 };
6370
6371 checkAnnos(&(yyvsp[(6) - (11)].optflags), annos);
6372
6373 if (currentSpec -> genc)
6374 {
6375 if ((yyvsp[(10) - (11)].codeb) == NULL && (yyvsp[(3) - (11)].signature).nrArgs != 0)
6376 yyerror("Constructors with arguments in C modules must include %MethodCode");
6377
6378 if (currentCtorIsExplicit)
6379 yyerror("Explicit constructors not allowed in a C module");
6380 }
6381
6382 if ((sectionFlags & (SECT_IS_PUBLIC | SECT_IS_PROT | SECT_IS_PRIVATE)) == 0)
6383 yyerror("Constructor must be in the public, private or protected sections");
6384
6385 newCtor(currentModule, (yyvsp[(1) - (11)].text), sectionFlags, &(yyvsp[(3) - (11)].signature), &(yyvsp[(6) - (11)].optflags), (yyvsp[(11) - (11)].codeb), (yyvsp[(5) - (11)].throwlist), (yyvsp[(7) - (11)].optsignature),
6386 currentCtorIsExplicit, (yyvsp[(9) - (11)].docstr), (yyvsp[(10) - (11)].codeb));
6387 }
6388
6389 free((yyvsp[(1) - (11)].text));
6390
6391 currentCtorIsExplicit = FALSE;
6392 }
6393 break;
6394
6395 case 417:
6396 #line 3404 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6397 {
6398 (yyval.optsignature) = NULL;
6399 }
6400 break;
6401
6402 case 418:
6403 #line 3407 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6404 {
6405 parsingCSignature = TRUE;
6406 }
6407 break;
6408
6409 case 419:
6410 #line 3409 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6411 {
6412 (yyval.optsignature) = sipMalloc(sizeof (signatureDef));
6413
6414 *(yyval.optsignature) = (yyvsp[(4) - (6)].signature);
6415
6416 parsingCSignature = FALSE;
6417 }
6418 break;
6419
6420 case 420:
6421 #line 3418 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6422 {
6423 (yyval.optsignature) = NULL;
6424 }
6425 break;
6426
6427 case 421:
6428 #line 3421 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6429 {
6430 parsingCSignature = TRUE;
6431 }
6432 break;
6433
6434 case 422:
6435 #line 3423 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6436 {
6437 (yyval.optsignature) = sipMalloc(sizeof (signatureDef));
6438
6439 *(yyval.optsignature) = (yyvsp[(5) - (7)].signature);
6440 (yyval.optsignature)->result = (yyvsp[(3) - (7)].memArg);
6441
6442 parsingCSignature = FALSE;
6443 }
6444 break;
6445
6446 case 423:
6447 #line 3433 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6448 {
6449 if (notSkipping())
6450 {
6451 applyTypeFlags(currentModule, &(yyvsp[(1) - (17)].memArg), &(yyvsp[(10) - (17)].optflags));
6452
6453 (yyvsp[(4) - (17)].signature).result = (yyvsp[(1) - (17)].memArg);
6454
6455 newFunction(currentSpec, currentModule, currentScope(), NULL,
6456 NULL, sectionFlags, currentIsStatic, currentIsSignal,
6457 currentIsSlot, currentIsVirt, (yyvsp[(2) - (17)].text), &(yyvsp[(4) - (17)].signature), (yyvsp[(6) - (17)].number), (yyvsp[(9) - (17)].number), &(yyvsp[(10) - (17)].optflags),
6458 (yyvsp[(15) - (17)].codeb), (yyvsp[(16) - (17)].codeb), (yyvsp[(17) - (17)].codeb), (yyvsp[(8) - (17)].throwlist), (yyvsp[(11) - (17)].optsignature), (yyvsp[(13) - (17)].docstr), (yyvsp[(7) - (17)].number), (yyvsp[(14) - (17)].codeb));
6459 }
6460
6461 currentIsStatic = FALSE;
6462 currentIsSignal = FALSE;
6463 currentIsSlot = FALSE;
6464 currentIsVirt = FALSE;
6465 }
6466 break;
6467
6468 case 424:
6469 #line 3451 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6470 {
6471 /*
6472 * It looks like an assignment operator (though we don't bother to
6473 * check the types) so make sure it is private.
6474 */
6475 if (notSkipping())
6476 {
6477 classDef *cd = currentScope();
6478
6479 if (cd == NULL || !(sectionFlags & SECT_IS_PRIVATE))
6480 yyerror("Assignment operators may only be defined as private");
6481
6482 setCannotAssign(cd);
6483 }
6484
6485 currentIsStatic = FALSE;
6486 currentIsSignal = FALSE;
6487 currentIsSlot = FALSE;
6488 currentIsVirt = FALSE;
6489 }
6490 break;
6491
6492 case 425:
6493 #line 3471 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6494 {
6495 if (notSkipping())
6496 {
6497 classDef *cd = currentScope();
6498 ifaceFileDef *ns_scope;
6499
6500 /*
6501 * If the scope is a namespace then make sure the operator is
6502 * handled as a global, but remember it's C++ scope..
6503 */
6504 if (cd != NULL && cd->iff->type == namespace_iface)
6505 {
6506 ns_scope = cd->iff;
6507 cd = NULL;
6508 }
6509 else
6510 {
6511 ns_scope = NULL;
6512 }
6513
6514 applyTypeFlags(currentModule, &(yyvsp[(1) - (17)].memArg), &(yyvsp[(11) - (17)].optflags));
6515
6516 /* Handle the unary '+' and '-' operators. */
6517 if ((cd != NULL && (yyvsp[(5) - (17)].signature).nrArgs == 0) || (cd == NULL && (yyvsp[(5) - (17)].signature).nrArgs == 1))
6518 {
6519 if (strcmp((yyvsp[(3) - (17)].text), "__add__") == 0)
6520 (yyvsp[(3) - (17)].text) = "__pos__";
6521 else if (strcmp((yyvsp[(3) - (17)].text), "__sub__") == 0)
6522 (yyvsp[(3) - (17)].text) = "__neg__";
6523 }
6524
6525 (yyvsp[(5) - (17)].signature).result = (yyvsp[(1) - (17)].memArg);
6526
6527 newFunction(currentSpec, currentModule, cd, ns_scope, NULL,
6528 sectionFlags, currentIsStatic, currentIsSignal,
6529 currentIsSlot, currentIsVirt, (yyvsp[(3) - (17)].text), &(yyvsp[(5) - (17)].signature), (yyvsp[(7) - (17)].number), (yyvsp[(10) - (17)].number), &(yyvsp[(11) - (17)].optflags),
6530 (yyvsp[(15) - (17)].codeb), (yyvsp[(16) - (17)].codeb), (yyvsp[(17) - (17)].codeb), (yyvsp[(9) - (17)].throwlist), (yyvsp[(12) - (17)].optsignature), NULL, (yyvsp[(8) - (17)].number), (yyvsp[(14) - (17)].codeb));
6531 }
6532
6533 currentIsStatic = FALSE;
6534 currentIsSignal = FALSE;
6535 currentIsSlot = FALSE;
6536 currentIsVirt = FALSE;
6537 }
6538 break;
6539
6540 case 426:
6541 #line 3515 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6542 {
6543 if (notSkipping())
6544 {
6545 char *sname;
6546 classDef *scope = currentScope();
6547
6548 if (scope == NULL || (yyvsp[(4) - (16)].signature).nrArgs != 0)
6549 yyerror("Operator casts must be specified in a class and have no arguments");
6550
6551 applyTypeFlags(currentModule, &(yyvsp[(2) - (16)].memArg), &(yyvsp[(10) - (16)].optflags));
6552
6553 switch ((yyvsp[(2) - (16)].memArg).atype)
6554 {
6555 case defined_type:
6556 sname = NULL;
6557 break;
6558
6559 case bool_type:
6560 case cbool_type:
6561 case byte_type:
6562 case sbyte_type:
6563 case ubyte_type:
6564 case short_type:
6565 case ushort_type:
6566 case int_type:
6567 case cint_type:
6568 case uint_type:
6569 case long_type:
6570 case ulong_type:
6571 case longlong_type:
6572 case ulonglong_type:
6573 sname = "__int__";
6574 break;
6575
6576 case float_type:
6577 case cfloat_type:
6578 case double_type:
6579 case cdouble_type:
6580 sname = "__float__";
6581 break;
6582
6583 default:
6584 yyerror("Unsupported operator cast");
6585 }
6586
6587 if (sname != NULL)
6588 {
6589 (yyvsp[(4) - (16)].signature).result = (yyvsp[(2) - (16)].memArg);
6590
6591 newFunction(currentSpec, currentModule, scope, NULL, NULL,
6592 sectionFlags, currentIsStatic, currentIsSignal,
6593 currentIsSlot, currentIsVirt, sname, &(yyvsp[(4) - (16)].signature), (yyvsp[(6) - (16)].number), (yyvsp[(9) - (16)].number),
6594 &(yyvsp[(10) - (16)].optflags), (yyvsp[(14) - (16)].codeb), (yyvsp[(15) - (16)].codeb), (yyvsp[(16) - (16)].codeb), (yyvsp[(8) - (16)].throwlist), (yyvsp[(11) - (16)].optsignature), NULL, (yyvsp[(7) - (16)].number), (yyvsp[(13) - (16)].codeb));
6595 }
6596 else
6597 {
6598 argList *al;
6599
6600 /* Check it doesn't already exist. */
6601 for (al = scope->casts; al != NULL; al = al->next)
6602 if (compareScopedNames((yyvsp[(2) - (16)].memArg).u.snd, al->arg.u.snd) == 0)
6603 yyerror("This operator cast has already been specified in this class");
6604
6605 al = sipMalloc(sizeof (argList));
6606 al->arg = (yyvsp[(2) - (16)].memArg);
6607 al->next = scope->casts;
6608
6609 scope->casts = al;
6610 }
6611 }
6612
6613 currentIsStatic = FALSE;
6614 currentIsSignal = FALSE;
6615 currentIsSlot = FALSE;
6616 currentIsVirt = FALSE;
6617 }
6618 break;
6619
6620 case 427:
6621 #line 3593 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6622 {(yyval.text) = "__add__";}
6623 break;
6624
6625 case 428:
6626 #line 3594 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6627 {(yyval.text) = "__sub__";}
6628 break;
6629
6630 case 429:
6631 #line 3595 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6632 {(yyval.text) = "__mul__";}
6633 break;
6634
6635 case 430:
6636 #line 3596 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6637 {(yyval.text) = "__truediv__";}
6638 break;
6639
6640 case 431:
6641 #line 3597 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6642 {(yyval.text) = "__mod__";}
6643 break;
6644
6645 case 432:
6646 #line 3598 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6647 {(yyval.text) = "__and__";}
6648 break;
6649
6650 case 433:
6651 #line 3599 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6652 {(yyval.text) = "__or__";}
6653 break;
6654
6655 case 434:
6656 #line 3600 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6657 {(yyval.text) = "__xor__";}
6658 break;
6659
6660 case 435:
6661 #line 3601 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6662 {(yyval.text) = "__lshift__";}
6663 break;
6664
6665 case 436:
6666 #line 3602 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6667 {(yyval.text) = "__rshift__";}
6668 break;
6669
6670 case 437:
6671 #line 3603 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6672 {(yyval.text) = "__iadd__";}
6673 break;
6674
6675 case 438:
6676 #line 3604 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6677 {(yyval.text) = "__isub__";}
6678 break;
6679
6680 case 439:
6681 #line 3605 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6682 {(yyval.text) = "__imul__";}
6683 break;
6684
6685 case 440:
6686 #line 3606 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6687 {(yyval.text) = "__itruediv__";}
6688 break;
6689
6690 case 441:
6691 #line 3607 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6692 {(yyval.text) = "__imod__";}
6693 break;
6694
6695 case 442:
6696 #line 3608 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6697 {(yyval.text) = "__iand__";}
6698 break;
6699
6700 case 443:
6701 #line 3609 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6702 {(yyval.text) = "__ior__";}
6703 break;
6704
6705 case 444:
6706 #line 3610 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6707 {(yyval.text) = "__ixor__";}
6708 break;
6709
6710 case 445:
6711 #line 3611 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6712 {(yyval.text) = "__ilshift__";}
6713 break;
6714
6715 case 446:
6716 #line 3612 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6717 {(yyval.text) = "__irshift__";}
6718 break;
6719
6720 case 447:
6721 #line 3613 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6722 {(yyval.text) = "__invert__";}
6723 break;
6724
6725 case 448:
6726 #line 3614 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6727 {(yyval.text) = "__call__";}
6728 break;
6729
6730 case 449:
6731 #line 3615 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6732 {(yyval.text) = "__getitem__";}
6733 break;
6734
6735 case 450:
6736 #line 3616 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6737 {(yyval.text) = "__lt__";}
6738 break;
6739
6740 case 451:
6741 #line 3617 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6742 {(yyval.text) = "__le__";}
6743 break;
6744
6745 case 452:
6746 #line 3618 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6747 {(yyval.text) = "__eq__";}
6748 break;
6749
6750 case 453:
6751 #line 3619 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6752 {(yyval.text) = "__ne__";}
6753 break;
6754
6755 case 454:
6756 #line 3620 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6757 {(yyval.text) = "__gt__";}
6758 break;
6759
6760 case 455:
6761 #line 3621 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6762 {(yyval.text) = "__ge__";}
6763 break;
6764
6765 case 456:
6766 #line 3624 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6767 {
6768 (yyval.number) = FALSE;
6769 }
6770 break;
6771
6772 case 457:
6773 #line 3627 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6774 {
6775 (yyval.number) = TRUE;
6776 }
6777 break;
6778
6779 case 458:
6780 #line 3632 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6781 {
6782 (yyval.number) = FALSE;
6783 }
6784 break;
6785
6786 case 459:
6787 #line 3635 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6788 {
6789 (yyval.number) = TRUE;
6790 }
6791 break;
6792
6793 case 460:
6794 #line 3640 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6795 {
6796 (yyval.number) = 0;
6797 }
6798 break;
6799
6800 case 461:
6801 #line 3643 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6802 {
6803 if ((yyvsp[(2) - (2)].number) != 0)
6804 yyerror("Abstract virtual function '= 0' expected");
6805
6806 (yyval.number) = TRUE;
6807 }
6808 break;
6809
6810 case 462:
6811 #line 3651 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6812 {
6813 (yyval.optflags).nrFlags = 0;
6814 }
6815 break;
6816
6817 case 463:
6818 #line 3654 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6819 {
6820 (yyval.optflags) = (yyvsp[(2) - (3)].optflags);
6821 }
6822 break;
6823
6824 case 464:
6825 #line 3660 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6826 {
6827 (yyval.optflags).flags[0] = (yyvsp[(1) - (1)].flag);
6828 (yyval.optflags).nrFlags = 1;
6829 }
6830 break;
6831
6832 case 465:
6833 #line 3664 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6834 {
6835 /* Check there is room. */
6836
6837 if ((yyvsp[(1) - (3)].optflags).nrFlags == MAX_NR_FLAGS)
6838 yyerror("Too many optional flags");
6839
6840 (yyval.optflags) = (yyvsp[(1) - (3)].optflags);
6841
6842 (yyval.optflags).flags[(yyval.optflags).nrFlags++] = (yyvsp[(3) - (3)].flag);
6843 }
6844 break;
6845
6846 case 466:
6847 #line 3676 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6848 {
6849 (yyval.flag).ftype = bool_flag;
6850 (yyval.flag).fname = (yyvsp[(1) - (1)].text);
6851 }
6852 break;
6853
6854 case 467:
6855 #line 3680 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6856 {
6857 (yyval.flag) = (yyvsp[(3) - (3)].flag);
6858 (yyval.flag).fname = (yyvsp[(1) - (3)].text);
6859 }
6860 break;
6861
6862 case 468:
6863 #line 3686 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6864 {
6865 (yyval.flag).ftype = (strchr((yyvsp[(1) - (1)].text), '.') != NULL) ? dotted_name_flag : name_flag;
6866 (yyval.flag).fvalue.sval = (yyvsp[(1) - (1)].text);
6867 }
6868 break;
6869
6870 case 469:
6871 #line 3690 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6872 {
6873 apiVersionRangeDef *avd;
6874 int from, to;
6875
6876 (yyval.flag).ftype = api_range_flag;
6877
6878 /* Check that the API is known. */
6879 if ((avd = findAPI(currentSpec, (yyvsp[(1) - (5)].text))) == NULL)
6880 yyerror("unknown API name in API annotation");
6881
6882 if (inMainModule())
6883 setIsUsedName(avd->api_name);
6884
6885 /* Unbounded values are represented by 0. */
6886 if ((from = (yyvsp[(3) - (5)].number)) < 0)
6887 from = 0;
6888
6889 if ((to = (yyvsp[(5) - (5)].number)) < 0)
6890 to = 0;
6891
6892 (yyval.flag).fvalue.aval = convertAPIRange(currentModule, avd->api_name,
6893 from, to);
6894 }
6895 break;
6896
6897 case 470:
6898 #line 3713 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6899 {
6900 (yyval.flag).ftype = string_flag;
6901 (yyval.flag).fvalue.sval = convertFeaturedString((yyvsp[(1) - (1)].text));
6902 }
6903 break;
6904
6905 case 471:
6906 #line 3717 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6907 {
6908 (yyval.flag).ftype = integer_flag;
6909 (yyval.flag).fvalue.ival = (yyvsp[(1) - (1)].number);
6910 }
6911 break;
6912
6913 case 472:
6914 #line 3723 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6915 {
6916 (yyval.codeb) = NULL;
6917 }
6918 break;
6919
6920 case 473:
6921 #line 3726 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6922 {
6923 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
6924 }
6925 break;
6926
6927 case 474:
6928 #line 3731 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6929 {
6930 (yyval.codeb) = NULL;
6931 }
6932 break;
6933
6934 case 475:
6935 #line 3734 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6936 {
6937 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
6938 }
6939 break;
6940
6941 case 476:
6942 #line 3739 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6943 {
6944 (yyval.codeb) = NULL;
6945 }
6946 break;
6947
6948 case 477:
6949 #line 3742 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6950 {
6951 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
6952 }
6953 break;
6954
6955 case 478:
6956 #line 3747 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6957 {
6958 (yyval.codeb) = NULL;
6959 }
6960 break;
6961
6962 case 479:
6963 #line 3750 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6964 {
6965 (yyval.codeb) = (yyvsp[(2) - (2)].codeb);
6966 }
6967 break;
6968
6969 case 480:
6970 #line 3755 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6971 {
6972 int a, nrarray, nrarraysize;
6973
6974 nrarray = nrarraysize = 0;
6975
6976 for (a = 0; a < (yyvsp[(1) - (1)].signature).nrArgs; ++a)
6977 {
6978 argDef *ad = &(yyvsp[(1) - (1)].signature).args[a];
6979
6980 if (isArray(ad))
6981 ++nrarray;
6982
6983 if (isArraySize(ad))
6984 ++nrarraysize;
6985 }
6986
6987 if (nrarray != nrarraysize || nrarray > 1)
6988 yyerror("/Array/ and /ArraySize/ must both be given and at most once");
6989
6990 (yyval.signature) = (yyvsp[(1) - (1)].signature);
6991 }
6992 break;
6993
6994 case 481:
6995 #line 3778 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
6996 {
6997 /* No arguments. */
6998
6999 (yyval.signature).nrArgs = 0;
7000 }
7001 break;
7002
7003 case 482:
7004 #line 3783 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7005 {
7006 /* The single or first argument. */
7007
7008 (yyval.signature).args[0] = (yyvsp[(1) - (1)].memArg);
7009 (yyval.signature).nrArgs = 1;
7010 }
7011 break;
7012
7013 case 483:
7014 #line 3789 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7015 {
7016 /* Check that it wasn't ...(,arg...). */
7017 if ((yyvsp[(1) - (3)].signature).nrArgs == 0)
7018 yyerror("First argument of the list is missing");
7019
7020 /*
7021 * If this argument has no default value, then the
7022 * previous one mustn't either.
7023 */
7024 if ((yyvsp[(3) - (3)].memArg).defval == NULL && (yyvsp[(1) - (3)].signature).args[(yyvsp[(1) - (3)].signature).nrArgs - 1].defval != NULL)
7025 yyerror("Compulsory argument given after optional argument");
7026
7027 /* Check there is room. */
7028 if ((yyvsp[(1) - (3)].signature).nrArgs == MAX_NR_ARGS)
7029 yyerror("Internal error - increase the value of MAX_NR_ARGS");
7030
7031 (yyval.signature) = (yyvsp[(1) - (3)].signature);
7032
7033 (yyval.signature).args[(yyval.signature).nrArgs] = (yyvsp[(3) - (3)].memArg);
7034 (yyval.signature).nrArgs++;
7035 }
7036 break;
7037
7038 case 484:
7039 #line 3812 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7040 {
7041 (yyval.memArg) = (yyvsp[(1) - (2)].memArg);
7042 (yyval.memArg).defval = (yyvsp[(2) - (2)].valp);
7043 }
7044 break;
7045
7046 case 485:
7047 #line 3819 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7048 {currentIsSignal = TRUE;}
7049 break;
7050
7051 case 487:
7052 #line 3820 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7053 {currentIsSlot = TRUE;}
7054 break;
7055
7056 case 490:
7057 #line 3825 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7058 {currentIsStatic = TRUE;}
7059 break;
7060
7061 case 495:
7062 #line 3835 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7063 {currentIsVirt = TRUE;}
7064 break;
7065
7066 case 498:
7067 #line 3839 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7068 {
7069 if (notSkipping())
7070 {
7071 const char *annos[] = {
7072 "Encoding",
7073 "NoSetter",
7074 "NoTypeHint",
7075 "PyInt",
7076 "PyName",
7077 "TypeHint",
7078 NULL
7079 };
7080
7081 checkAnnos(&(yyvsp[(3) - (5)].optflags), annos);
7082
7083 newVar(currentSpec, currentModule, (yyvsp[(2) - (5)].text), currentIsStatic, &(yyvsp[(1) - (5)].memArg),
7084 &(yyvsp[(3) - (5)].optflags), (yyvsp[(4) - (5)].variable).access_code, (yyvsp[(4) - (5)].variable).get_code, (yyvsp[(4) - (5)].variable).set_code,
7085 sectionFlags);
7086 }
7087
7088 currentIsStatic = FALSE;
7089 }
7090 break;
7091
7092 case 499:
7093 #line 3863 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7094 {
7095 (yyval.variable).token = 0;
7096 (yyval.variable).access_code = NULL;
7097 (yyval.variable).get_code = NULL;
7098 (yyval.variable).set_code = NULL;
7099 }
7100 break;
7101
7102 case 500:
7103 #line 3869 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7104 {
7105 (yyval.variable) = (yyvsp[(2) - (3)].variable);
7106 }
7107 break;
7108
7109 case 502:
7110 #line 3875 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7111 {
7112 (yyval.variable) = (yyvsp[(1) - (2)].variable);
7113
7114 switch ((yyvsp[(2) - (2)].variable).token)
7115 {
7116 case TK_ACCESSCODE: (yyval.variable).access_code = (yyvsp[(2) - (2)].variable).access_code; break;
7117 case TK_GETCODE: (yyval.variable).get_code = (yyvsp[(2) - (2)].variable).get_code; break;
7118 case TK_SETCODE: (yyval.variable).set_code = (yyvsp[(2) - (2)].variable).set_code; break;
7119 }
7120 }
7121 break;
7122
7123 case 503:
7124 #line 3887 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7125 {
7126 (yyval.variable).token = TK_IF;
7127 }
7128 break;
7129
7130 case 504:
7131 #line 3890 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7132 {
7133 (yyval.variable).token = TK_END;
7134 }
7135 break;
7136
7137 case 505:
7138 #line 3893 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7139 {
7140 if (notSkipping())
7141 {
7142 (yyval.variable).token = TK_ACCESSCODE;
7143 (yyval.variable).access_code = (yyvsp[(2) - (2)].codeb);
7144 }
7145 else
7146 {
7147 (yyval.variable).token = 0;
7148 (yyval.variable).access_code = NULL;
7149 }
7150
7151 (yyval.variable).get_code = NULL;
7152 (yyval.variable).set_code = NULL;
7153 }
7154 break;
7155
7156 case 506:
7157 #line 3908 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7158 {
7159 if (notSkipping())
7160 {
7161 (yyval.variable).token = TK_GETCODE;
7162 (yyval.variable).get_code = (yyvsp[(2) - (2)].codeb);
7163 }
7164 else
7165 {
7166 (yyval.variable).token = 0;
7167 (yyval.variable).get_code = NULL;
7168 }
7169
7170 (yyval.variable).access_code = NULL;
7171 (yyval.variable).set_code = NULL;
7172 }
7173 break;
7174
7175 case 507:
7176 #line 3923 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7177 {
7178 if (notSkipping())
7179 {
7180 (yyval.variable).token = TK_SETCODE;
7181 (yyval.variable).set_code = (yyvsp[(2) - (2)].codeb);
7182 }
7183 else
7184 {
7185 (yyval.variable).token = 0;
7186 (yyval.variable).set_code = NULL;
7187 }
7188
7189 (yyval.variable).access_code = NULL;
7190 (yyval.variable).get_code = NULL;
7191 }
7192 break;
7193
7194 case 508:
7195 #line 3940 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7196 {
7197 (yyval.memArg) = (yyvsp[(2) - (4)].memArg);
7198 add_derefs(&(yyval.memArg), &(yyvsp[(3) - (4)].memArg));
7199 (yyval.memArg).argflags |= ARG_IS_CONST | (yyvsp[(4) - (4)].number);
7200 }
7201 break;
7202
7203 case 509:
7204 #line 3945 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7205 {
7206 (yyval.memArg) = (yyvsp[(1) - (3)].memArg);
7207 add_derefs(&(yyval.memArg), &(yyvsp[(2) - (3)].memArg));
7208 (yyval.memArg).argflags |= (yyvsp[(3) - (3)].number);
7209
7210 /* PyObject * is a synonym for SIP_PYOBJECT. */
7211 if ((yyvsp[(1) - (3)].memArg).atype == defined_type && strcmp((yyvsp[(1) - (3)].memArg).u.snd->name, "PyObject") == 0 && (yyvsp[(1) - (3)].memArg).u.snd->next == NULL && (yyvsp[(2) - (3)].memArg).nrderefs == 1 && (yyvsp[(3) - (3)].number) == 0)
7212 {
7213 (yyval.memArg).atype = pyobject_type;
7214 (yyval.memArg).nrderefs = 0;
7215 }
7216 }
7217 break;
7218
7219 case 510:
7220 #line 3959 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7221 {
7222 const char *annos[] = {
7223 "AllowNone",
7224 "Array",
7225 "ArraySize",
7226 "Constrained",
7227 "DisallowNone",
7228 "Encoding",
7229 "GetWrapper",
7230 "In",
7231 "KeepReference",
7232 "NoCopy",
7233 "Out",
7234 "PyInt",
7235 "ResultSize",
7236 "ScopesStripped",
7237 "Transfer",
7238 "TransferBack",
7239 "TransferThis",
7240 "TypeHint",
7241 "TypeHintIn",
7242 "TypeHintOut",
7243 "TypeHintValue",
7244 NULL
7245 };
7246
7247 optFlag *of;
7248
7249 checkAnnos(&(yyvsp[(3) - (3)].optflags), annos);
7250
7251 (yyval.memArg) = (yyvsp[(1) - (3)].memArg);
7252 (yyval.memArg).name = cacheName(currentSpec, (yyvsp[(2) - (3)].text));
7253
7254 handleKeepReference(&(yyvsp[(3) - (3)].optflags), &(yyval.memArg), currentModule);
7255
7256 if ((of = getOptFlag(&(yyvsp[(3) - (3)].optflags), "ScopesStripped", opt_integer_flag)) != NULL)
7257 if (((yyval.memArg).scopes_stripped = of->fvalue.ival) <= 0)
7258 yyerror("/ScopesStripped/ must be greater than 0");
7259
7260 if (getAllowNone(&(yyvsp[(3) - (3)].optflags)))
7261 (yyval.memArg).argflags |= ARG_ALLOW_NONE;
7262
7263 if (getDisallowNone(&(yyvsp[(3) - (3)].optflags)))
7264 (yyval.memArg).argflags |= ARG_DISALLOW_NONE;
7265
7266 if (getOptFlag(&(yyvsp[(3) - (3)].optflags),"GetWrapper",bool_flag) != NULL)
7267 (yyval.memArg).argflags |= ARG_GET_WRAPPER;
7268
7269 if (getOptFlag(&(yyvsp[(3) - (3)].optflags),"Array",bool_flag) != NULL)
7270 (yyval.memArg).argflags |= ARG_ARRAY;
7271
7272 if (getOptFlag(&(yyvsp[(3) - (3)].optflags),"ArraySize",bool_flag) != NULL)
7273 (yyval.memArg).argflags |= ARG_ARRAY_SIZE;
7274
7275 if (getTransfer(&(yyvsp[(3) - (3)].optflags)))
7276 (yyval.memArg).argflags |= ARG_XFERRED;
7277
7278 if (getOptFlag(&(yyvsp[(3) - (3)].optflags),"TransferThis",bool_flag) != NULL)
7279 (yyval.memArg).argflags |= ARG_THIS_XFERRED;
7280
7281 if (getOptFlag(&(yyvsp[(3) - (3)].optflags),"TransferBack",bool_flag) != NULL)
7282 (yyval.memArg).argflags |= ARG_XFERRED_BACK;
7283
7284 if (getOptFlag(&(yyvsp[(3) - (3)].optflags),"In",bool_flag) != NULL)
7285 (yyval.memArg).argflags |= ARG_IN;
7286
7287 if (getOptFlag(&(yyvsp[(3) - (3)].optflags),"Out",bool_flag) != NULL)
7288 (yyval.memArg).argflags |= ARG_OUT;
7289
7290 if (getOptFlag(&(yyvsp[(3) - (3)].optflags), "ResultSize", bool_flag) != NULL)
7291 (yyval.memArg).argflags |= ARG_RESULT_SIZE;
7292
7293 if (getOptFlag(&(yyvsp[(3) - (3)].optflags), "NoCopy", bool_flag) != NULL)
7294 (yyval.memArg).argflags |= ARG_NO_COPY;
7295
7296 if (getOptFlag(&(yyvsp[(3) - (3)].optflags),"Constrained",bool_flag) != NULL)
7297 {
7298 (yyval.memArg).argflags |= ARG_CONSTRAINED;
7299
7300 switch ((yyval.memArg).atype)
7301 {
7302 case bool_type:
7303 (yyval.memArg).atype = cbool_type;
7304 break;
7305
7306 case int_type:
7307 (yyval.memArg).atype = cint_type;
7308 break;
7309
7310 case float_type:
7311 (yyval.memArg).atype = cfloat_type;
7312 break;
7313
7314 case double_type:
7315 (yyval.memArg).atype = cdouble_type;
7316 break;
7317
7318 /* Suppress a compiler warning. */
7319 default:
7320 ;
7321 }
7322 }
7323
7324 applyTypeFlags(currentModule, &(yyval.memArg), &(yyvsp[(3) - (3)].optflags));
7325 (yyval.memArg).typehint_value = getTypeHintValue(&(yyvsp[(3) - (3)].optflags));
7326 }
7327 break;
7328
7329 case 511:
7330 #line 4067 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7331 {
7332 (yyval.number) = 0;
7333 }
7334 break;
7335
7336 case 512:
7337 #line 4070 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7338 {
7339 if (currentSpec -> genc)
7340 yyerror("References not allowed in a C module");
7341
7342 (yyval.number) = ARG_IS_REF;
7343 }
7344 break;
7345
7346 case 513:
7347 #line 4078 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7348 {
7349 (yyval.memArg).nrderefs = 0;
7350 }
7351 break;
7352
7353 case 514:
7354 #line 4081 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7355 {
7356 add_new_deref(&(yyval.memArg), &(yyvsp[(1) - (3)].memArg), TRUE);
7357 }
7358 break;
7359
7360 case 515:
7361 #line 4084 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7362 {
7363 add_new_deref(&(yyval.memArg), &(yyvsp[(1) - (2)].memArg), FALSE);
7364 }
7365 break;
7366
7367 case 516:
7368 #line 4089 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7369 {
7370 memset(&(yyval.memArg), 0, sizeof (argDef));
7371 (yyval.memArg).atype = defined_type;
7372 (yyval.memArg).u.snd = (yyvsp[(1) - (1)].scpvalp);
7373
7374 /* Try and resolve typedefs as early as possible. */
7375 resolveAnyTypedef(currentSpec, &(yyval.memArg));
7376 }
7377 break;
7378
7379 case 517:
7380 #line 4097 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7381 {
7382 templateDef *td;
7383
7384 td = sipMalloc(sizeof(templateDef));
7385 td->fqname = (yyvsp[(1) - (4)].scpvalp);
7386 td->types = (yyvsp[(3) - (4)].signature);
7387
7388 memset(&(yyval.memArg), 0, sizeof (argDef));
7389 (yyval.memArg).atype = template_type;
7390 (yyval.memArg).u.td = td;
7391 }
7392 break;
7393
7394 case 518:
7395 #line 4108 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7396 {
7397 memset(&(yyval.memArg), 0, sizeof (argDef));
7398
7399 /* In a C module all structures must be defined. */
7400 if (currentSpec -> genc)
7401 {
7402 (yyval.memArg).atype = defined_type;
7403 (yyval.memArg).u.snd = (yyvsp[(2) - (2)].scpvalp);
7404 }
7405 else
7406 {
7407 (yyval.memArg).atype = struct_type;
7408 (yyval.memArg).u.sname = (yyvsp[(2) - (2)].scpvalp);
7409 }
7410 }
7411 break;
7412
7413 case 519:
7414 #line 4123 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7415 {
7416 memset(&(yyval.memArg), 0, sizeof (argDef));
7417 (yyval.memArg).atype = ushort_type;
7418 }
7419 break;
7420
7421 case 520:
7422 #line 4127 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7423 {
7424 memset(&(yyval.memArg), 0, sizeof (argDef));
7425 (yyval.memArg).atype = short_type;
7426 }
7427 break;
7428
7429 case 521:
7430 #line 4131 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7431 {
7432 memset(&(yyval.memArg), 0, sizeof (argDef));
7433 (yyval.memArg).atype = uint_type;
7434 }
7435 break;
7436
7437 case 522:
7438 #line 4135 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7439 {
7440 memset(&(yyval.memArg), 0, sizeof (argDef));
7441 (yyval.memArg).atype = uint_type;
7442 }
7443 break;
7444
7445 case 523:
7446 #line 4139 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7447 {
7448 memset(&(yyval.memArg), 0, sizeof (argDef));
7449 (yyval.memArg).atype = int_type;
7450 }
7451 break;
7452
7453 case 524:
7454 #line 4143 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7455 {
7456 memset(&(yyval.memArg), 0, sizeof (argDef));
7457 (yyval.memArg).atype = long_type;
7458 }
7459 break;
7460
7461 case 525:
7462 #line 4147 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7463 {
7464 memset(&(yyval.memArg), 0, sizeof (argDef));
7465 (yyval.memArg).atype = ulong_type;
7466 }
7467 break;
7468
7469 case 526:
7470 #line 4151 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7471 {
7472 memset(&(yyval.memArg), 0, sizeof (argDef));
7473 (yyval.memArg).atype = longlong_type;
7474 }
7475 break;
7476
7477 case 527:
7478 #line 4155 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7479 {
7480 memset(&(yyval.memArg), 0, sizeof (argDef));
7481 (yyval.memArg).atype = ulonglong_type;
7482 }
7483 break;
7484
7485 case 528:
7486 #line 4159 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7487 {
7488 memset(&(yyval.memArg), 0, sizeof (argDef));
7489 (yyval.memArg).atype = float_type;
7490 }
7491 break;
7492
7493 case 529:
7494 #line 4163 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7495 {
7496 memset(&(yyval.memArg), 0, sizeof (argDef));
7497 (yyval.memArg).atype = double_type;
7498 }
7499 break;
7500
7501 case 530:
7502 #line 4167 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7503 {
7504 memset(&(yyval.memArg), 0, sizeof (argDef));
7505 (yyval.memArg).atype = bool_type;
7506 }
7507 break;
7508
7509 case 531:
7510 #line 4171 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7511 {
7512 memset(&(yyval.memArg), 0, sizeof (argDef));
7513 (yyval.memArg).atype = sstring_type;
7514 }
7515 break;
7516
7517 case 532:
7518 #line 4175 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7519 {
7520 memset(&(yyval.memArg), 0, sizeof (argDef));
7521 (yyval.memArg).atype = ustring_type;
7522 }
7523 break;
7524
7525 case 533:
7526 #line 4179 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7527 {
7528 memset(&(yyval.memArg), 0, sizeof (argDef));
7529 (yyval.memArg).atype = string_type;
7530 }
7531 break;
7532
7533 case 534:
7534 #line 4183 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7535 {
7536 memset(&(yyval.memArg), 0, sizeof (argDef));
7537 (yyval.memArg).atype = wstring_type;
7538 }
7539 break;
7540
7541 case 535:
7542 #line 4187 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7543 {
7544 memset(&(yyval.memArg), 0, sizeof (argDef));
7545 (yyval.memArg).atype = void_type;
7546 }
7547 break;
7548
7549 case 536:
7550 #line 4191 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7551 {
7552 memset(&(yyval.memArg), 0, sizeof (argDef));
7553 (yyval.memArg).atype = pyobject_type;
7554 }
7555 break;
7556
7557 case 537:
7558 #line 4195 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7559 {
7560 memset(&(yyval.memArg), 0, sizeof (argDef));
7561 (yyval.memArg).atype = pytuple_type;
7562 }
7563 break;
7564
7565 case 538:
7566 #line 4199 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7567 {
7568 memset(&(yyval.memArg), 0, sizeof (argDef));
7569 (yyval.memArg).atype = pylist_type;
7570 }
7571 break;
7572
7573 case 539:
7574 #line 4203 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7575 {
7576 memset(&(yyval.memArg), 0, sizeof (argDef));
7577 (yyval.memArg).atype = pydict_type;
7578 }
7579 break;
7580
7581 case 540:
7582 #line 4207 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7583 {
7584 memset(&(yyval.memArg), 0, sizeof (argDef));
7585 (yyval.memArg).atype = pycallable_type;
7586 }
7587 break;
7588
7589 case 541:
7590 #line 4211 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7591 {
7592 memset(&(yyval.memArg), 0, sizeof (argDef));
7593 (yyval.memArg).atype = pyslice_type;
7594 }
7595 break;
7596
7597 case 542:
7598 #line 4215 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7599 {
7600 memset(&(yyval.memArg), 0, sizeof (argDef));
7601 (yyval.memArg).atype = pytype_type;
7602 }
7603 break;
7604
7605 case 543:
7606 #line 4219 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7607 {
7608 memset(&(yyval.memArg), 0, sizeof (argDef));
7609 (yyval.memArg).atype = pybuffer_type;
7610 }
7611 break;
7612
7613 case 544:
7614 #line 4223 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7615 {
7616 memset(&(yyval.memArg), 0, sizeof (argDef));
7617 (yyval.memArg).atype = ssize_type;
7618 }
7619 break;
7620
7621 case 545:
7622 #line 4227 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7623 {
7624 memset(&(yyval.memArg), 0, sizeof (argDef));
7625 (yyval.memArg).atype = size_type;
7626 }
7627 break;
7628
7629 case 546:
7630 #line 4231 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7631 {
7632 memset(&(yyval.memArg), 0, sizeof (argDef));
7633 (yyval.memArg).atype = ellipsis_type;
7634 }
7635 break;
7636
7637 case 547:
7638 #line 4237 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7639 {
7640 /* The single or first type. */
7641
7642 (yyval.signature).args[0] = (yyvsp[(1) - (1)].memArg);
7643 (yyval.signature).nrArgs = 1;
7644 }
7645 break;
7646
7647 case 548:
7648 #line 4243 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7649 {
7650 /* Check there is nothing after an ellipsis. */
7651 if ((yyvsp[(1) - (3)].signature).args[(yyvsp[(1) - (3)].signature).nrArgs - 1].atype == ellipsis_type)
7652 yyerror("An ellipsis must be at the end of the argument list");
7653
7654 /* Check there is room. */
7655 if ((yyvsp[(1) - (3)].signature).nrArgs == MAX_NR_ARGS)
7656 yyerror("Internal error - increase the value of MAX_NR_ARGS");
7657
7658 (yyval.signature) = (yyvsp[(1) - (3)].signature);
7659
7660 (yyval.signature).args[(yyval.signature).nrArgs] = (yyvsp[(3) - (3)].memArg);
7661 (yyval.signature).nrArgs++;
7662 }
7663 break;
7664
7665 case 549:
7666 #line 4259 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7667 {
7668 (yyval.throwlist) = NULL;
7669 }
7670 break;
7671
7672 case 550:
7673 #line 4262 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7674 {
7675 if (currentSpec->genc)
7676 yyerror("Exceptions not allowed in a C module");
7677
7678 (yyval.throwlist) = (yyvsp[(3) - (4)].throwlist);
7679 }
7680 break;
7681
7682 case 551:
7683 #line 4270 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7684 {
7685 /* Empty list so use a blank. */
7686
7687 (yyval.throwlist) = sipMalloc(sizeof (throwArgs));
7688 (yyval.throwlist) -> nrArgs = 0;
7689 }
7690 break;
7691
7692 case 552:
7693 #line 4276 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7694 {
7695 /* The only or first exception. */
7696
7697 (yyval.throwlist) = sipMalloc(sizeof (throwArgs));
7698 (yyval.throwlist) -> nrArgs = 1;
7699 (yyval.throwlist) -> args[0] = findException(currentSpec, (yyvsp[(1) - (1)].scpvalp), FALSE);
7700 }
7701 break;
7702
7703 case 553:
7704 #line 4283 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7705 {
7706 /* Check that it wasn't ...(,arg...). */
7707
7708 if ((yyvsp[(1) - (3)].throwlist) -> nrArgs == 0)
7709 yyerror("First exception of throw specifier is missing");
7710
7711 /* Check there is room. */
7712
7713 if ((yyvsp[(1) - (3)].throwlist) -> nrArgs == MAX_NR_ARGS)
7714 yyerror("Internal error - increase the value of MAX_NR_ARGS");
7715
7716 (yyval.throwlist) = (yyvsp[(1) - (3)].throwlist);
7717 (yyval.throwlist) -> args[(yyval.throwlist) -> nrArgs++] = findException(currentSpec, (yyvsp[(3) - (3)].scpvalp), FALSE);
7718 }
7719 break;
7720
7721
7722 /* Line 1267 of yacc.c. */
7723 #line 7724 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/parser.c"
7724 default: break;
7725 }
7726 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
7727
7728 YYPOPSTACK (yylen);
7729 yylen = 0;
7730 YY_STACK_PRINT (yyss, yyssp);
7731
7732 *++yyvsp = yyval;
7733
7734
7735 /* Now `shift' the result of the reduction. Determine what state
7736 that goes to, based on the state we popped back to and the rule
7737 number reduced by. */
7738
7739 yyn = yyr1[yyn];
7740
7741 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
7742 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
7743 yystate = yytable[yystate];
7744 else
7745 yystate = yydefgoto[yyn - YYNTOKENS];
7746
7747 goto yynewstate;
7748
7749
7750 /*------------------------------------.
7751 | yyerrlab -- here on detecting error |
7752 `------------------------------------*/
7753 yyerrlab:
7754 /* If not already recovering from an error, report this error. */
7755 if (!yyerrstatus)
7756 {
7757 ++yynerrs;
7758 #if ! YYERROR_VERBOSE
7759 yyerror (YY_("syntax error"));
7760 #else
7761 {
7762 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
7763 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
7764 {
7765 YYSIZE_T yyalloc = 2 * yysize;
7766 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
7767 yyalloc = YYSTACK_ALLOC_MAXIMUM;
7768 if (yymsg != yymsgbuf)
7769 YYSTACK_FREE (yymsg);
7770 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
7771 if (yymsg)
7772 yymsg_alloc = yyalloc;
7773 else
7774 {
7775 yymsg = yymsgbuf;
7776 yymsg_alloc = sizeof yymsgbuf;
7777 }
7778 }
7779
7780 if (0 < yysize && yysize <= yymsg_alloc)
7781 {
7782 (void) yysyntax_error (yymsg, yystate, yychar);
7783 yyerror (yymsg);
7784 }
7785 else
7786 {
7787 yyerror (YY_("syntax error"));
7788 if (yysize != 0)
7789 goto yyexhaustedlab;
7790 }
7791 }
7792 #endif
7793 }
7794
7795
7796
7797 if (yyerrstatus == 3)
7798 {
7799 /* If just tried and failed to reuse look-ahead token after an
7800 error, discard it. */
7801
7802 if (yychar <= YYEOF)
7803 {
7804 /* Return failure if at end of input. */
7805 if (yychar == YYEOF)
7806 YYABORT;
7807 }
7808 else
7809 {
7810 yydestruct ("Error: discarding",
7811 yytoken, &yylval);
7812 yychar = YYEMPTY;
7813 }
7814 }
7815
7816 /* Else will try to reuse look-ahead token after shifting the error
7817 token. */
7818 goto yyerrlab1;
7819
7820
7821 /*---------------------------------------------------.
7822 | yyerrorlab -- error raised explicitly by YYERROR. |
7823 `---------------------------------------------------*/
7824 yyerrorlab:
7825
7826 /* Pacify compilers like GCC when the user code never invokes
7827 YYERROR and the label yyerrorlab therefore never appears in user
7828 code. */
7829 if (/*CONSTCOND*/ 0)
7830 goto yyerrorlab;
7831
7832 /* Do not reclaim the symbols of the rule which action triggered
7833 this YYERROR. */
7834 YYPOPSTACK (yylen);
7835 yylen = 0;
7836 YY_STACK_PRINT (yyss, yyssp);
7837 yystate = *yyssp;
7838 goto yyerrlab1;
7839
7840
7841 /*-------------------------------------------------------------.
7842 | yyerrlab1 -- common code for both syntax error and YYERROR. |
7843 `-------------------------------------------------------------*/
7844 yyerrlab1:
7845 yyerrstatus = 3; /* Each real token shifted decrements this. */
7846
7847 for (;;)
7848 {
7849 yyn = yypact[yystate];
7850 if (yyn != YYPACT_NINF)
7851 {
7852 yyn += YYTERROR;
7853 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7854 {
7855 yyn = yytable[yyn];
7856 if (0 < yyn)
7857 break;
7858 }
7859 }
7860
7861 /* Pop the current state because it cannot handle the error token. */
7862 if (yyssp == yyss)
7863 YYABORT;
7864
7865
7866 yydestruct ("Error: popping",
7867 yystos[yystate], yyvsp);
7868 YYPOPSTACK (1);
7869 yystate = *yyssp;
7870 YY_STACK_PRINT (yyss, yyssp);
7871 }
7872
7873 if (yyn == YYFINAL)
7874 YYACCEPT;
7875
7876 *++yyvsp = yylval;
7877
7878
7879 /* Shift the error token. */
7880 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
7881
7882 yystate = yyn;
7883 goto yynewstate;
7884
7885
7886 /*-------------------------------------.
7887 | yyacceptlab -- YYACCEPT comes here. |
7888 `-------------------------------------*/
7889 yyacceptlab:
7890 yyresult = 0;
7891 goto yyreturn;
7892
7893 /*-----------------------------------.
7894 | yyabortlab -- YYABORT comes here. |
7895 `-----------------------------------*/
7896 yyabortlab:
7897 yyresult = 1;
7898 goto yyreturn;
7899
7900 #ifndef yyoverflow
7901 /*-------------------------------------------------.
7902 | yyexhaustedlab -- memory exhaustion comes here. |
7903 `-------------------------------------------------*/
7904 yyexhaustedlab:
7905 yyerror (YY_("memory exhausted"));
7906 yyresult = 2;
7907 /* Fall through. */
7908 #endif
7909
7910 yyreturn:
7911 if (yychar != YYEOF && yychar != YYEMPTY)
7912 yydestruct ("Cleanup: discarding lookahead",
7913 yytoken, &yylval);
7914 /* Do not reclaim the symbols of the rule which action triggered
7915 this YYABORT or YYACCEPT. */
7916 YYPOPSTACK (yylen);
7917 YY_STACK_PRINT (yyss, yyssp);
7918 while (yyssp != yyss)
7919 {
7920 yydestruct ("Cleanup: popping",
7921 yystos[*yyssp], yyvsp);
7922 YYPOPSTACK (1);
7923 }
7924 #ifndef yyoverflow
7925 if (yyss != yyssa)
7926 YYSTACK_FREE (yyss);
7927 #endif
7928 #if YYERROR_VERBOSE
7929 if (yymsg != yymsgbuf)
7930 YYSTACK_FREE (yymsg);
7931 #endif
7932 /* Make sure YYID is used. */
7933 return YYID (yyresult);
7934 }
7935
7936
7937 #line 4299 "/private/var/folders/h1/_bwlktg15kldvnwlfn_tc5c00000gn/T/tmpdnw69_wq/sip/code_generator/metasrc/parser.y"
7938
7939
7940
7941 /*
7942 * Parse the specification.
7943 */
parse(sipSpec * spec,FILE * fp,char * filename,int strict,stringList ** tsl,stringList * bsl,stringList ** xfl,int protHack,stringList ** sip_files)7944 void parse(sipSpec *spec, FILE *fp, char *filename, int strict,
7945 stringList **tsl, stringList *bsl, stringList **xfl, int protHack,
7946 stringList **sip_files)
7947 {
7948 classTmplDef *tcd;
7949
7950 initialiseLexer();
7951
7952 /* Initialise the spec. */
7953
7954 memset(spec, 0, sizeof (sipSpec));
7955 spec->genc = -1;
7956
7957 currentSpec = spec;
7958 strictParse = strict;
7959 backstops = bsl;
7960 neededQualifiers = *tsl;
7961 excludedQualifiers = *xfl;
7962 currentModule = NULL;
7963 currentMappedType = NULL;
7964 currentIsVirt = FALSE;
7965 currentCtorIsExplicit = FALSE;
7966 currentIsStatic = FALSE;
7967 currentIsSignal = FALSE;
7968 currentIsSlot = FALSE;
7969 currentIsTemplate = FALSE;
7970 previousFile = NULL;
7971 stackPtr = 0;
7972 currentPlatforms = NULL;
7973 currentScopeIdx = 0;
7974 sectionFlags = 0;
7975 defaultKwArgs = NoKwArgs;
7976 makeProtPublic = protHack;
7977 mainModuleSipFiles = sip_files;
7978
7979 newModule(fp, filename);
7980 spec->module = currentModule;
7981
7982 yyparse();
7983
7984 handleEOF();
7985 handleEOM();
7986
7987 /*
7988 * Go through each template class and remove it from the list of classes.
7989 */
7990 for (tcd = spec->classtemplates; tcd != NULL; tcd = tcd->next)
7991 {
7992 classDef **cdp;
7993
7994 for (cdp = &spec->classes; *cdp != NULL; cdp = &(*cdp)->next)
7995 if (*cdp == tcd->cd)
7996 {
7997 ifaceFileDef **ifdp;
7998
7999 /* Remove the interface file as well. */
8000 for (ifdp = &spec->ifacefiles; *ifdp != NULL; ifdp = &(*ifdp)->next)
8001 if (*ifdp == tcd->cd->iff)
8002 {
8003 *ifdp = (*ifdp)->next;
8004 break;
8005 }
8006
8007 *cdp = (*cdp)->next;
8008 break;
8009 }
8010 }
8011
8012 /* These may have been updated from imported bindings. */
8013 *tsl = neededQualifiers;
8014 *xfl = excludedQualifiers;
8015 }
8016
8017
8018 /*
8019 * Tell the parser that a complete file has now been read.
8020 */
parserEOF(const char * name,parserContext * pc)8021 void parserEOF(const char *name, parserContext *pc)
8022 {
8023 previousFile = sipStrdup(name);
8024 currentContext = *pc;
8025 }
8026
8027
8028 /*
8029 * Append a class definition to a class list if it doesn't already appear.
8030 * Append is needed specifically for the list of super-classes because the
8031 * order is important to Python.
8032 */
appendToClassList(classList ** clp,classDef * cd)8033 void appendToClassList(classList **clp,classDef *cd)
8034 {
8035 classList *new;
8036
8037 /* Find the end of the list. */
8038
8039 while (*clp != NULL)
8040 {
8041 if ((*clp) -> cd == cd)
8042 return;
8043
8044 clp = &(*clp) -> next;
8045 }
8046
8047 new = sipMalloc(sizeof (classList));
8048
8049 new -> cd = cd;
8050 new -> next = NULL;
8051
8052 *clp = new;
8053 }
8054
8055
8056 /*
8057 * Create a new module for the current specification and make it current.
8058 */
newModule(FILE * fp,const char * filename)8059 static void newModule(FILE *fp, const char *filename)
8060 {
8061 moduleDef *mod;
8062
8063 parseFile(fp, filename, currentModule, FALSE);
8064
8065 mod = allocModule();
8066 mod->file = filename;
8067
8068 if (currentModule != NULL)
8069 mod->defexception = currentModule->defexception;
8070
8071 currentModule = mod;
8072 }
8073
8074
8075 /*
8076 * Allocate and initialise the memory for a new module.
8077 */
allocModule(void)8078 static moduleDef *allocModule(void)
8079 {
8080 moduleDef *newmod, **tailp;
8081
8082 newmod = sipMalloc(sizeof (moduleDef));
8083
8084 newmod->defdocstringfmt = raw;
8085 newmod->encoding = no_type;
8086 newmod->next_key = -1;
8087
8088 /*
8089 * The consolidated module support needs these to be in order that they
8090 * appeared.
8091 */
8092 for (tailp = ¤tSpec->modules; *tailp != NULL; tailp = &(*tailp)->next)
8093 ;
8094
8095 *tailp = newmod;
8096
8097 return newmod;
8098 }
8099
8100
8101 /*
8102 * Switch to parsing a new file.
8103 */
parseFile(FILE * fp,const char * name,moduleDef * prevmod,int optional)8104 static void parseFile(FILE *fp, const char *name, moduleDef *prevmod,
8105 int optional)
8106 {
8107 parserContext pc;
8108
8109 pc.filename = name;
8110 pc.ifdepth = stackPtr;
8111 pc.prevmod = prevmod;
8112
8113 if (setInputFile(fp, &pc, optional))
8114 {
8115 currentContext = pc;
8116
8117 /* Save the name of the file if this is the main module. */
8118 if (prevmod == NULL)
8119 appendString(mainModuleSipFiles, sipStrdup(name));
8120 }
8121 }
8122
8123
8124 /*
8125 * Find an interface file, or create a new one.
8126 */
findIfaceFile(sipSpec * pt,moduleDef * mod,scopedNameDef * fqname,ifaceFileType iftype,apiVersionRangeDef * api_range,argDef * ad)8127 ifaceFileDef *findIfaceFile(sipSpec *pt, moduleDef *mod, scopedNameDef *fqname,
8128 ifaceFileType iftype, apiVersionRangeDef *api_range, argDef *ad)
8129 {
8130 ifaceFileDef *iff, *first_alt = NULL;
8131
8132 /* See if the name is already used. */
8133
8134 for (iff = pt->ifacefiles; iff != NULL; iff = iff->next)
8135 {
8136 if (compareScopedNames(iff->fqcname, fqname) != 0)
8137 continue;
8138
8139 /*
8140 * If they are both versioned then assume the user knows what they are
8141 * doing.
8142 */
8143 if (iff->api_range != NULL && api_range != NULL && iff->module == mod)
8144 {
8145 /* Remember the first of the alternate APIs. */
8146 if ((first_alt = iff->first_alt) == NULL)
8147 first_alt = iff;
8148
8149 break;
8150 }
8151
8152 /*
8153 * They must be the same type except that we allow a class if we want
8154 * an exception. This is because we allow classes to be used before
8155 * they are defined.
8156 */
8157 if (iff->type != iftype)
8158 if (iftype != exception_iface || iff->type != class_iface)
8159 yyerror("A class, exception, namespace or mapped type has already been defined with the same name");
8160
8161 /* Ignore an external class declared in another module. */
8162 if (iftype == class_iface && iff->module != mod)
8163 {
8164 classDef *cd;
8165
8166 for (cd = pt->classes; cd != NULL; cd = cd->next)
8167 if (cd->iff == iff)
8168 break;
8169
8170 if (cd != NULL && iff->module != NULL && isExternal(cd))
8171 continue;
8172 }
8173
8174 /*
8175 * If this is a mapped type with the same name defined in a different
8176 * module, then check that this type isn't the same as any of the
8177 * mapped types defined in that module.
8178 */
8179 if (iftype == mappedtype_iface && iff->module != mod)
8180 {
8181 mappedTypeDef *mtd;
8182
8183 /*
8184 * This is a bit of a cheat. With consolidated modules it's
8185 * possible to have two implementations of a mapped type in
8186 * different branches of the module hierarchy. We assume that, if
8187 * there really are multiple implementations in the same branch,
8188 * then it will be picked up in a non-consolidated build.
8189 */
8190 if (isConsolidated(pt->module))
8191 continue;
8192
8193 for (mtd = pt->mappedtypes; mtd != NULL; mtd = mtd->next)
8194 {
8195 if (mtd->iff != iff)
8196 continue;
8197
8198 if (ad->atype != template_type ||
8199 mtd->type.atype != template_type ||
8200 sameBaseType(ad, &mtd->type))
8201 yyerror("Mapped type has already been defined in another module");
8202 }
8203
8204 /*
8205 * If we got here then we have a mapped type based on an existing
8206 * template, but with unique parameters. We don't want to use
8207 * interface files from other modules, so skip this one.
8208 */
8209
8210 continue;
8211 }
8212
8213 /* Ignore a namespace defined in another module. */
8214 if (iftype == namespace_iface && iff->module != mod)
8215 continue;
8216
8217 return iff;
8218 }
8219
8220 iff = sipMalloc(sizeof (ifaceFileDef));
8221
8222 iff->name = cacheName(pt, scopedNameToString(fqname));
8223 iff->api_range = api_range;
8224
8225 if (first_alt != NULL)
8226 {
8227 iff->first_alt = first_alt;
8228 iff->next_alt = first_alt->next_alt;
8229
8230 first_alt->next_alt = iff;
8231 }
8232 else
8233 {
8234 /* This is the first alternate so point to itself. */
8235 iff->first_alt = iff;
8236 }
8237
8238 /*
8239 * Note that we assume that the type (ie. class vs. mapped type vs.
8240 * exception) will be the same across all platforms.
8241 */
8242 iff->platforms = currentPlatforms;
8243
8244 iff->type = iftype;
8245 iff->ifacenr = -1;
8246 iff->fqcname = fqname;
8247 iff->module = NULL;
8248 iff->hdrcode = NULL;
8249 iff->used = NULL;
8250 iff->file_extension = NULL;
8251 iff->next = pt->ifacefiles;
8252
8253 pt->ifacefiles = iff;
8254
8255 return iff;
8256 }
8257
8258
8259 /*
8260 * Find a class definition in a parse tree.
8261 */
findClass(sipSpec * pt,ifaceFileType iftype,apiVersionRangeDef * api_range,scopedNameDef * fqname,int tmpl_arg)8262 static classDef *findClass(sipSpec *pt, ifaceFileType iftype,
8263 apiVersionRangeDef *api_range, scopedNameDef *fqname, int tmpl_arg)
8264 {
8265 return findClassWithInterface(pt,
8266 findIfaceFile(pt, currentModule, fqname, iftype, api_range, NULL),
8267 tmpl_arg);
8268 }
8269
8270
8271 /*
8272 * Find a class definition given an existing interface file.
8273 */
findClassWithInterface(sipSpec * pt,ifaceFileDef * iff,int tmpl_arg)8274 static classDef *findClassWithInterface(sipSpec *pt, ifaceFileDef *iff,
8275 int tmpl_arg)
8276 {
8277 classDef *cd;
8278
8279 for (cd = pt->classes; cd != NULL; cd = cd->next)
8280 if (cd->iff == iff)
8281 {
8282 if (isTemplateArg(cd) && !tmpl_arg)
8283 resetTemplateArg(cd);
8284
8285 return cd;
8286 }
8287
8288 /* Create a new one. */
8289 cd = sipMalloc(sizeof (classDef));
8290
8291 if (tmpl_arg)
8292 setTemplateArg(cd);
8293
8294 cd->iff = iff;
8295 cd->pyname = cacheName(pt, classBaseName(cd));
8296 cd->next = pt->classes;
8297
8298 pt->classes = cd;
8299
8300 return cd;
8301 }
8302
8303
8304 /*
8305 * Add an interface file to an interface file list if it isn't already there.
8306 */
appendToIfaceFileList(ifaceFileList ** ifflp,ifaceFileDef * iff)8307 void appendToIfaceFileList(ifaceFileList **ifflp, ifaceFileDef *iff)
8308 {
8309 /* Make sure we don't try to add an interface file to its own list. */
8310 if (&iff->used != ifflp)
8311 {
8312 ifaceFileList *iffl;
8313
8314 while ((iffl = *ifflp) != NULL)
8315 {
8316 /* Don't bother if it is already there. */
8317 if (iffl->iff == iff)
8318 return;
8319
8320 ifflp = &iffl -> next;
8321 }
8322
8323 iffl = sipMalloc(sizeof (ifaceFileList));
8324
8325 iffl->iff = iff;
8326 iffl->next = NULL;
8327
8328 *ifflp = iffl;
8329 }
8330 }
8331
8332
8333 /*
8334 * Find an undefined (or create a new) exception definition in a parse tree.
8335 */
findException(sipSpec * pt,scopedNameDef * fqname,int new)8336 static exceptionDef *findException(sipSpec *pt, scopedNameDef *fqname, int new)
8337 {
8338 exceptionDef *xd, **tail;
8339 ifaceFileDef *iff;
8340 classDef *cd;
8341
8342 iff = findIfaceFile(pt, currentModule, fqname, exception_iface, NULL, NULL);
8343
8344 /* See if it is an existing one. */
8345 for (xd = pt->exceptions; xd != NULL; xd = xd->next)
8346 if (xd->iff == iff)
8347 return xd;
8348
8349 /*
8350 * If it is an exception interface file then we have never seen this name
8351 * before. We require that exceptions are defined before being used, but
8352 * don't make the same requirement of classes (for reasons of backwards
8353 * compatibility). Therefore the name must be reinterpreted as a (as yet
8354 * undefined) class.
8355 */
8356 if (new)
8357 {
8358 if (iff->type == exception_iface)
8359 cd = NULL;
8360 else
8361 yyerror("There is already a class with the same name or the exception has been used before being defined");
8362 }
8363 else
8364 {
8365 if (iff->type == exception_iface)
8366 iff->type = class_iface;
8367
8368 cd = findClassWithInterface(pt, iff, FALSE);
8369 }
8370
8371 /* Create a new one. */
8372 xd = sipMalloc(sizeof (exceptionDef));
8373
8374 xd->exceptionnr = -1;
8375 xd->needed = FALSE;
8376 xd->iff = iff;
8377 xd->pyname = NULL;
8378 xd->cd = cd;
8379 xd->bibase = NULL;
8380 xd->base = NULL;
8381 xd->raisecode = NULL;
8382 xd->next = NULL;
8383
8384 /* Append it to the list. */
8385 for (tail = &pt->exceptions; *tail != NULL; tail = &(*tail)->next)
8386 ;
8387
8388 *tail = xd;
8389
8390 return xd;
8391 }
8392
8393
8394 /*
8395 * Find an undefined (or create a new) class definition in a parse tree.
8396 */
newClass(sipSpec * pt,ifaceFileType iftype,apiVersionRangeDef * api_range,scopedNameDef * fqname,const char * virt_error_handler,typeHintDef * typehint_in,typeHintDef * typehint_out,const char * typehint_value)8397 static classDef *newClass(sipSpec *pt, ifaceFileType iftype,
8398 apiVersionRangeDef *api_range, scopedNameDef *fqname,
8399 const char *virt_error_handler, typeHintDef *typehint_in,
8400 typeHintDef *typehint_out, const char *typehint_value)
8401 {
8402 int flags;
8403 classDef *cd, *scope;
8404 codeBlockList *hdrcode;
8405
8406 if (sectionFlags & SECT_IS_PRIVATE)
8407 yyerror("Classes, structs and namespaces must be in the public or protected sections");
8408
8409 flags = 0;
8410
8411 if ((scope = currentScope()) != NULL)
8412 {
8413 if (sectionFlags & SECT_IS_PROT && !makeProtPublic)
8414 {
8415 flags = CLASS_IS_PROTECTED;
8416
8417 if (scope->iff->type == class_iface)
8418 setNeedsShadow(scope);
8419 }
8420
8421 /* Header code from outer scopes is also included. */
8422 hdrcode = scope->iff->hdrcode;
8423 }
8424 else
8425 hdrcode = NULL;
8426
8427 if (pt -> genc)
8428 {
8429 /* C structs are always global types. */
8430 while (fqname -> next != NULL)
8431 fqname = fqname -> next;
8432
8433 scope = NULL;
8434 }
8435
8436 cd = findClass(pt, iftype, api_range, fqname, FALSE);
8437
8438 /* Check it hasn't already been defined. */
8439 if (iftype != namespace_iface && cd->iff->module != NULL)
8440 yyerror("The struct/class has already been defined");
8441
8442 /* Complete the initialisation. */
8443 cd->classflags |= flags;
8444 cd->ecd = scope;
8445 cd->iff->module = currentModule;
8446 cd->virt_error_handler = virt_error_handler;
8447 cd->typehint_in = typehint_in;
8448 cd->typehint_out = typehint_out;
8449 cd->typehint_value = typehint_value;
8450
8451 if (currentIsTemplate)
8452 setIsTemplateClass(cd);
8453
8454 appendCodeBlockList(&cd->iff->hdrcode, hdrcode);
8455
8456 /* See if it is a namespace extender. */
8457 if (iftype == namespace_iface)
8458 {
8459 classDef *ns;
8460
8461 for (ns = pt->classes; ns != NULL; ns = ns->next)
8462 {
8463 if (ns == cd)
8464 continue;
8465
8466 if (ns->iff->type != namespace_iface)
8467 continue;
8468
8469 if (compareScopedNames(ns->iff->fqcname, fqname) != 0)
8470 continue;
8471
8472 cd->real = ns;
8473
8474 if (inMainModule())
8475 ns->iff->first_alt->needed = TRUE;
8476
8477 break;
8478 }
8479 }
8480
8481 return cd;
8482 }
8483
8484
8485 /*
8486 * Tidy up after finishing a class definition.
8487 */
finishClass(sipSpec * pt,moduleDef * mod,classDef * cd,optFlags * of)8488 static void finishClass(sipSpec *pt, moduleDef *mod, classDef *cd,
8489 optFlags *of)
8490 {
8491 const char *pyname;
8492 optFlag *flg;
8493
8494 /* Get the Python name and see if it is different to the C++ name. */
8495 pyname = getPythonName(mod, of, classBaseName(cd));
8496
8497 cd->pyname = NULL;
8498 checkAttributes(pt, mod, cd->ecd, NULL, pyname, FALSE);
8499 cd->pyname = cacheName(pt, pyname);
8500 cd->no_typehint = getNoTypeHint(of);
8501
8502 if ((flg = getOptFlag(of, "Metatype", dotted_name_flag)) != NULL)
8503 cd->metatype = cacheName(pt, flg->fvalue.sval);
8504
8505 if ((flg = getOptFlag(of, "Supertype", dotted_name_flag)) != NULL)
8506 cd->supertype = cacheName(pt, flg->fvalue.sval);
8507
8508 if (getOptFlag(of, "ExportDerived", bool_flag) != NULL)
8509 setExportDerived(cd);
8510
8511 if (getOptFlag(of, "Mixin", bool_flag) != NULL)
8512 setMixin(cd);
8513
8514 if ((flg = getOptFlag(of, "FileExtension", string_flag)) != NULL)
8515 cd->iff->file_extension = flg->fvalue.sval;
8516
8517 if ((flg = getOptFlag(of, "PyQtFlagsEnums", string_list_flag)) != NULL)
8518 {
8519 cd->pyqt_flags_enums = flg->fvalue.slval;
8520 cd->pyqt_flags = 1;
8521 }
8522
8523 /* This is deprecated and only used by versions before v5.12. */
8524 if ((flg = getOptFlag(of, "PyQtFlags", integer_flag)) != NULL)
8525 cd->pyqt_flags = flg->fvalue.ival;
8526
8527 if (getOptFlag(of, "PyQtNoQMetaObject", bool_flag) != NULL)
8528 setPyQtNoQMetaObject(cd);
8529
8530 if ((flg = getOptFlag(of, "PyQtInterface", string_flag)) != NULL)
8531 cd->pyqt_interface = flg->fvalue.sval;
8532
8533 if (isOpaque(cd))
8534 {
8535 if (getOptFlag(of, "External", bool_flag) != NULL)
8536 setIsExternal(cd);
8537 }
8538 else
8539 {
8540 int seq_might, seq_not, default_to_sequence;
8541 memberDef *md;
8542
8543 if (getOptFlag(of, "NoDefaultCtors", bool_flag) != NULL)
8544 setNoDefaultCtors(cd);
8545
8546 if (cd -> ctors == NULL)
8547 {
8548 if (!noDefaultCtors(cd))
8549 {
8550 /* Provide a default ctor. */
8551
8552 cd->ctors = sipMalloc(sizeof (ctorDef));
8553
8554 cd->ctors->ctorflags = SECT_IS_PUBLIC;
8555 cd->ctors->pysig.result.atype = void_type;
8556 cd->ctors->cppsig = &cd->ctors->pysig;
8557
8558 cd->defctor = cd->ctors;
8559
8560 setCanCreate(cd);
8561 }
8562 }
8563 else if (cd -> defctor == NULL)
8564 {
8565 ctorDef *ct, *last = NULL;
8566
8567 for (ct = cd -> ctors; ct != NULL; ct = ct -> next)
8568 {
8569 if (!isPublicCtor(ct))
8570 continue;
8571
8572 if (ct -> pysig.nrArgs == 0 || ct -> pysig.args[0].defval != NULL)
8573 {
8574 cd -> defctor = ct;
8575 break;
8576 }
8577
8578 if (last == NULL)
8579 last = ct;
8580 }
8581
8582 /* The last resort is the first public ctor. */
8583 if (cd->defctor == NULL)
8584 cd->defctor = last;
8585 }
8586
8587 if (getDeprecated(of))
8588 setIsDeprecatedClass(cd);
8589
8590 if (cd->convtocode != NULL && getAllowNone(of))
8591 setClassHandlesNone(cd);
8592
8593 if (getOptFlag(of,"Abstract",bool_flag) != NULL)
8594 {
8595 setIsAbstractClass(cd);
8596 setIsIncomplete(cd);
8597 resetCanCreate(cd);
8598 }
8599
8600 /* We assume a public dtor if nothing specific was provided. */
8601 if (!isDtor(cd))
8602 setIsPublicDtor(cd);
8603
8604 if (getOptFlag(of, "DelayDtor", bool_flag) != NULL)
8605 {
8606 setIsDelayedDtor(cd);
8607 setHasDelayedDtors(mod);
8608 }
8609
8610 /*
8611 * There are subtle differences between the add and concat methods and
8612 * the multiply and repeat methods. The number versions can have their
8613 * operands swapped and may return NotImplemented. If the user has
8614 * used the /Numeric/ annotation or there are other numeric operators
8615 * then we use add/multiply. Otherwise, if the user has used the
8616 * /Sequence/ annotation or there are indexing operators then we use
8617 * concat/repeat.
8618 */
8619 seq_might = seq_not = FALSE;
8620
8621 for (md = cd->members; md != NULL; md = md->next)
8622 switch (md->slot)
8623 {
8624 case getitem_slot:
8625 case setitem_slot:
8626 case delitem_slot:
8627 /* This might be a sequence. */
8628 seq_might = TRUE;
8629 break;
8630
8631 case sub_slot:
8632 case isub_slot:
8633 case mod_slot:
8634 case imod_slot:
8635 case floordiv_slot:
8636 case ifloordiv_slot:
8637 case truediv_slot:
8638 case itruediv_slot:
8639 case pos_slot:
8640 case neg_slot:
8641 /* This is definately not a sequence. */
8642 seq_not = TRUE;
8643 break;
8644
8645 /* Suppress a compiler warning. */
8646 default:
8647 ;
8648 }
8649
8650 default_to_sequence = (!seq_not && seq_might);
8651
8652 for (md = cd->members; md != NULL; md = md->next)
8653 {
8654 /* Ignore if it is explicitly numeric. */
8655 if (isNumeric(md))
8656 continue;
8657
8658 if (isSequence(md) || default_to_sequence)
8659 switch (md->slot)
8660 {
8661 case add_slot:
8662 md->slot = concat_slot;
8663 break;
8664
8665 case iadd_slot:
8666 md->slot = iconcat_slot;
8667 break;
8668
8669 case mul_slot:
8670 md->slot = repeat_slot;
8671 break;
8672
8673 case imul_slot:
8674 md->slot = irepeat_slot;
8675 break;
8676
8677 /* Suppress a compiler warning. */
8678 default:
8679 ;
8680 }
8681 }
8682 }
8683
8684 if (inMainModule())
8685 {
8686 setIsUsedName(cd->iff->name);
8687 setIsUsedName(cd->pyname);
8688 }
8689 }
8690
8691
8692 /*
8693 * Return the encoded name of a template (ie. including its argument types) as
8694 * a scoped name.
8695 */
encodedTemplateName(templateDef * td)8696 scopedNameDef *encodedTemplateName(templateDef *td)
8697 {
8698 int a;
8699 scopedNameDef *snd;
8700
8701 snd = copyScopedName(td->fqname);
8702
8703 for (a = 0; a < td->types.nrArgs; ++a)
8704 {
8705 char buf[50];
8706 int flgs;
8707 scopedNameDef *arg_snd;
8708 argDef *ad = &td->types.args[a];
8709
8710 flgs = 0;
8711
8712 if (isConstArg(ad))
8713 flgs += 1;
8714
8715 if (isReference(ad))
8716 flgs += 2;
8717
8718 /* We use numbers so they don't conflict with names. */
8719 sprintf(buf, "%02d%d%d", ad->atype, flgs, ad->nrderefs);
8720
8721 switch (ad->atype)
8722 {
8723 case defined_type:
8724 arg_snd = copyScopedName(ad->u.snd);
8725 break;
8726
8727 case template_type:
8728 arg_snd = encodedTemplateName(ad->u.td);
8729 break;
8730
8731 case struct_type:
8732 arg_snd = copyScopedName(ad->u.sname);
8733 break;
8734
8735 default:
8736 arg_snd = NULL;
8737 }
8738
8739 /*
8740 * Replace the first element of the argument name with a copy with the
8741 * encoding prepended.
8742 */
8743 if (arg_snd != NULL)
8744 arg_snd->name = concat(buf, arg_snd->name, NULL);
8745 else
8746 arg_snd = text2scopePart(sipStrdup(buf));
8747
8748 appendScopedName(&snd, arg_snd);
8749 }
8750
8751 return snd;
8752 }
8753
8754
8755 /*
8756 * Create a new mapped type.
8757 */
newMappedType(sipSpec * pt,argDef * ad,optFlags * of)8758 static mappedTypeDef *newMappedType(sipSpec *pt, argDef *ad, optFlags *of)
8759 {
8760 mappedTypeDef *mtd;
8761 scopedNameDef *snd;
8762 ifaceFileDef *iff;
8763 const char *cname;
8764
8765 /* Check that the type is one we want to map. */
8766 switch (ad->atype)
8767 {
8768 case defined_type:
8769 snd = ad->u.snd = fullyQualifiedName(ad->u.snd);
8770 cname = scopedNameTail(snd);
8771 break;
8772
8773 case template_type:
8774 ad->u.td->fqname = fullyQualifiedName(ad->u.td->fqname);
8775 snd = encodedTemplateName(ad->u.td);
8776 cname = NULL;
8777 break;
8778
8779 case struct_type:
8780 snd = ad->u.sname = fullyQualifiedName(ad->u.sname);
8781 cname = scopedNameTail(snd);
8782 break;
8783
8784 default:
8785 yyerror("Invalid type for %MappedType");
8786 }
8787
8788 iff = findIfaceFile(pt, currentModule, snd, mappedtype_iface,
8789 getAPIRange(of), ad);
8790
8791 /* Check it hasn't already been defined. */
8792 for (mtd = pt->mappedtypes; mtd != NULL; mtd = mtd->next)
8793 if (mtd->iff == iff)
8794 {
8795 /*
8796 * We allow types based on the same template but with different
8797 * arguments.
8798 */
8799 if (ad->atype != template_type || sameBaseType(ad, &mtd->type))
8800 yyerror("Mapped type has already been defined in this module");
8801 }
8802
8803 /* The module may not have been set yet. */
8804 iff->module = currentModule;
8805
8806 /* Create a new mapped type. */
8807 mtd = allocMappedType(pt, ad);
8808
8809 if (cname != NULL)
8810 mtd->pyname = cacheName(pt, getPythonName(currentModule, of, cname));
8811
8812 mappedTypeAnnos(mtd, of);
8813
8814 mtd->iff = iff;
8815 mtd->next = pt->mappedtypes;
8816
8817 pt->mappedtypes = mtd;
8818
8819 if (inMainModule())
8820 {
8821 setIsUsedName(mtd->cname);
8822
8823 if (mtd->pyname)
8824 setIsUsedName(mtd->pyname);
8825 }
8826
8827 return mtd;
8828 }
8829
8830
8831 /*
8832 * Allocate, initialise and return a mapped type structure.
8833 */
allocMappedType(sipSpec * pt,argDef * type)8834 mappedTypeDef *allocMappedType(sipSpec *pt, argDef *type)
8835 {
8836 mappedTypeDef *mtd;
8837
8838 mtd = sipMalloc(sizeof (mappedTypeDef));
8839
8840 mtd->type = *type;
8841 mtd->type.argflags = 0;
8842 mtd->type.nrderefs = 0;
8843
8844 mtd->cname = cacheName(pt, type2string(&mtd->type));
8845
8846 /* Keep track of the original definition as it gets copied. */
8847 mtd->real = mtd;
8848
8849 return mtd;
8850 }
8851
8852
8853 /*
8854 * Create a new enum.
8855 */
newEnum(sipSpec * pt,moduleDef * mod,mappedTypeDef * mt_scope,char * name,optFlags * of,int flags,int isscoped)8856 static enumDef *newEnum(sipSpec *pt, moduleDef *mod, mappedTypeDef *mt_scope,
8857 char *name, optFlags *of, int flags, int isscoped)
8858 {
8859 enumDef *ed, *first_alt, *next_alt;
8860 classDef *c_scope;
8861 ifaceFileDef *scope;
8862
8863 if (mt_scope != NULL)
8864 {
8865 scope = mt_scope->iff;
8866 c_scope = NULL;
8867 }
8868 else
8869 {
8870 if ((c_scope = currentScope()) != NULL)
8871 scope = c_scope->iff;
8872 else
8873 scope = NULL;
8874 }
8875
8876 ed = sipMalloc(sizeof (enumDef));
8877
8878 /* Assume the enum isn't versioned. */
8879 first_alt = ed;
8880 next_alt = NULL;
8881
8882 if (name != NULL)
8883 {
8884 ed->pyname = cacheName(pt, getPythonName(mod, of, name));
8885 checkAttributes(pt, mod, c_scope, mt_scope, ed->pyname->text, FALSE);
8886
8887 ed->fqcname = text2scopedName(scope, name);
8888 ed->cname = cacheName(pt, scopedNameToString(ed->fqcname));
8889
8890 if (inMainModule())
8891 {
8892 setIsUsedName(ed->pyname);
8893 setIsUsedName(ed->cname);
8894 }
8895
8896 /* If the scope is versioned then look for any alternate. */
8897 if (scope != NULL && scope->api_range != NULL)
8898 {
8899 enumDef *alt;
8900
8901 for (alt = pt->enums; alt != NULL; alt = alt->next)
8902 {
8903 if (alt->module != mod || alt->fqcname == NULL)
8904 continue;
8905
8906 if (compareScopedNames(alt->fqcname, ed->fqcname) == 0)
8907 {
8908 first_alt = alt->first_alt;
8909 next_alt = first_alt->next_alt;
8910 first_alt->next_alt = ed;
8911
8912 break;
8913 }
8914 }
8915 }
8916 }
8917 else
8918 {
8919 ed->pyname = NULL;
8920 ed->fqcname = NULL;
8921 ed->cname = NULL;
8922 }
8923
8924 if (flags & SECT_IS_PROT)
8925 {
8926 if (makeProtPublic)
8927 {
8928 flags &= ~SECT_IS_PROT;
8929 flags |= SECT_IS_PUBLIC;
8930 }
8931 else if (c_scope != NULL)
8932 {
8933 setNeedsShadow(c_scope);
8934 }
8935 }
8936
8937 ed->enumflags = flags;
8938 ed->no_typehint = getNoTypeHint(of);
8939 ed->enumnr = -1;
8940 ed->ecd = c_scope;
8941 ed->emtd = mt_scope;
8942 ed->first_alt = first_alt;
8943 ed->next_alt = next_alt;
8944 ed->module = mod;
8945 ed->members = NULL;
8946 ed->slots = NULL;
8947 ed->overs = NULL;
8948 ed->platforms = currentPlatforms;
8949 ed->next = pt -> enums;
8950
8951 pt->enums = ed;
8952
8953 if (getOptFlag(of, "NoScope", bool_flag) != NULL)
8954 setIsNoScope(ed);
8955
8956 if (isscoped)
8957 setIsScopedEnum(ed);
8958
8959 return ed;
8960 }
8961
8962
8963 /*
8964 * Get the type values and (optionally) the type names for substitution in
8965 * handwritten code.
8966 */
appendTypeStrings(scopedNameDef * ename,signatureDef * patt,signatureDef * src,signatureDef * known,scopedNameDef ** names,scopedNameDef ** values)8967 void appendTypeStrings(scopedNameDef *ename, signatureDef *patt, signatureDef *src, signatureDef *known, scopedNameDef **names, scopedNameDef **values)
8968 {
8969 int a;
8970
8971 for (a = 0; a < patt->nrArgs; ++a)
8972 {
8973 argDef *pad = &patt->args[a];
8974
8975 if (pad->atype == defined_type)
8976 {
8977 char *nam = NULL, *val;
8978 argDef *sad;
8979
8980 /*
8981 * If the type names are already known then check that this is one
8982 * of them.
8983 */
8984 if (known == NULL)
8985 nam = scopedNameTail(pad->u.snd);
8986 else if (pad->u.snd->next == NULL)
8987 {
8988 int k;
8989
8990 for (k = 0; k < known->nrArgs; ++k)
8991 {
8992 /* Skip base types. */
8993 if (known->args[k].atype != defined_type)
8994 continue;
8995
8996 if (strcmp(pad->u.snd->name, known->args[k].u.snd->name) == 0)
8997 {
8998 nam = pad->u.snd->name;
8999 break;
9000 }
9001 }
9002 }
9003
9004 if (nam == NULL)
9005 continue;
9006
9007 /* Add the name. */
9008 appendScopedName(names, text2scopePart(nam));
9009
9010 /*
9011 * Add the corresponding value. For defined types we don't want
9012 * any indirection or references.
9013 */
9014 sad = &src->args[a];
9015
9016 if (sad->atype == defined_type)
9017 val = scopedNameToString(sad->u.snd);
9018 else
9019 val = type2string(sad);
9020
9021 /* We do want const. */
9022 if (isConstArg(sad))
9023 {
9024 char *const_val = sipStrdup("const ");
9025
9026 append(&const_val, val);
9027 free(val);
9028
9029 val = const_val;
9030 }
9031
9032 appendScopedName(values, text2scopePart(val));
9033 }
9034 else if (pad->atype == template_type)
9035 {
9036 argDef *sad = &src->args[a];
9037
9038 /* These checks shouldn't be necessary, but... */
9039 if (sad->atype == template_type && pad->u.td->types.nrArgs == sad->u.td->types.nrArgs)
9040 appendTypeStrings(ename, &pad->u.td->types, &sad->u.td->types, known, names, values);
9041 }
9042 }
9043 }
9044
9045
9046 /*
9047 * Convert a type to a string on the heap. The string will use the minimum
9048 * whitespace while still remaining valid C++.
9049 */
type2string(argDef * ad)9050 static char *type2string(argDef *ad)
9051 {
9052 int i, on_heap = FALSE;
9053 int nr_derefs = ad->nrderefs;
9054 int is_reference = isReference(ad);
9055 char *s;
9056
9057 /* Use the original type if possible. */
9058 if (ad->original_type != NULL && !noTypeName(ad->original_type))
9059 {
9060 s = scopedNameToString(ad->original_type->fqname);
9061 on_heap = TRUE;
9062
9063 nr_derefs -= ad->original_type->type.nrderefs;
9064
9065 if (isReference(&ad->original_type->type))
9066 is_reference = FALSE;
9067 }
9068 else
9069 switch (ad->atype)
9070 {
9071 case template_type:
9072 {
9073 templateDef *td = ad->u.td;
9074
9075 s = scopedNameToString(td->fqname);
9076 append(&s, "<");
9077
9078 for (i = 0; i < td->types.nrArgs; ++i)
9079 {
9080 char *sub_type = type2string(&td->types.args[i]);
9081
9082 if (i > 0)
9083 append(&s, ",");
9084
9085 append(&s, sub_type);
9086 free(sub_type);
9087 }
9088
9089 if (s[strlen(s) - 1] == '>')
9090 append(&s, " >");
9091 else
9092 append(&s, ">");
9093
9094 on_heap = TRUE;
9095 break;
9096 }
9097
9098 case struct_type:
9099 s = scopedNameToString(ad->u.sname);
9100 on_heap = TRUE;
9101 break;
9102
9103 case defined_type:
9104 s = scopedNameToString(ad->u.snd);
9105 on_heap = TRUE;
9106 break;
9107
9108 case ubyte_type:
9109 case ustring_type:
9110 s = "unsigned char";
9111 break;
9112
9113 case byte_type:
9114 case ascii_string_type:
9115 case latin1_string_type:
9116 case utf8_string_type:
9117 case string_type:
9118 s = "char";
9119 break;
9120
9121 case sbyte_type:
9122 case sstring_type:
9123 s = "signed char";
9124 break;
9125
9126 case wstring_type:
9127 s = "wchar_t";
9128 break;
9129
9130 case ushort_type:
9131 s = "unsigned short";
9132 break;
9133
9134 case short_type:
9135 s = "short";
9136 break;
9137
9138 case uint_type:
9139 s = "uint";
9140 break;
9141
9142 case int_type:
9143 case cint_type:
9144 s = "int";
9145 break;
9146
9147 case ulong_type:
9148 s = "unsigned long";
9149 break;
9150
9151 case long_type:
9152 s = "long";
9153 break;
9154
9155 case ulonglong_type:
9156 s = "unsigned long long";
9157 break;
9158
9159 case longlong_type:
9160 s = "long long";
9161 break;
9162
9163 case float_type:
9164 case cfloat_type:
9165 s = "float";
9166 break;
9167
9168 case double_type:
9169 case cdouble_type:
9170 s = "double";
9171 break;
9172
9173 case bool_type:
9174 case cbool_type:
9175 s = "bool";
9176 break;
9177
9178 case void_type:
9179 s = "void";
9180 break;
9181
9182 case capsule_type:
9183 s = "void *";
9184 break;
9185
9186 case size_type:
9187 s = "size_t";
9188 break;
9189
9190 default:
9191 fatal("Unsupported type argument to type2string(): %d\n", ad->atype);
9192 }
9193
9194 /* Make sure the string is on the heap. */
9195 if (!on_heap)
9196 s = sipStrdup(s);
9197
9198 while (nr_derefs-- > 0)
9199 append(&s, "*");
9200
9201 if (is_reference)
9202 append(&s, "&");
9203
9204 return s;
9205 }
9206
9207
9208 /*
9209 * Remove any explicit global scope.
9210 */
removeGlobalScope(scopedNameDef * snd)9211 scopedNameDef *removeGlobalScope(scopedNameDef *snd)
9212 {
9213 return ((snd != NULL && snd->name[0] == '\0') ? snd->next : snd);
9214 }
9215
9216
9217 /*
9218 * Convert a scoped name to a string on the heap.
9219 */
scopedNameToString(scopedNameDef * name)9220 static char *scopedNameToString(scopedNameDef *name)
9221 {
9222 static const char scope_string[] = "::";
9223 size_t len;
9224 scopedNameDef *snd;
9225 char *s, *dp;
9226
9227 /*
9228 * We don't want the global scope (which probably should always be there,
9229 * but we check anyway).
9230 */
9231 name = removeGlobalScope(name);
9232
9233 /* Work out the length of buffer needed. */
9234 len = 0;
9235
9236 for (snd = name; snd != NULL; snd = snd->next)
9237 {
9238 len += strlen(snd->name);
9239
9240 if (snd->next != NULL)
9241 {
9242 /* Ignore the encoded part of template names. */
9243 if (isdigit(snd->next->name[0]))
9244 break;
9245
9246 len += strlen(scope_string);
9247 }
9248 }
9249
9250 /* Allocate and populate the buffer. */
9251 dp = s = sipMalloc(len + 1);
9252
9253 for (snd = name; snd != NULL; snd = snd->next)
9254 {
9255 strcpy(dp, snd->name);
9256 dp += strlen(snd->name);
9257
9258 if (snd->next != NULL)
9259 {
9260 /* Ignore the encoded part of template names. */
9261 if (isdigit(snd->next->name[0]))
9262 break;
9263
9264 strcpy(dp, scope_string);
9265 dp += strlen(scope_string);
9266 }
9267 }
9268
9269 return s;
9270 }
9271
9272
9273 /*
9274 * Instantiate a class template.
9275 */
instantiateClassTemplate(sipSpec * pt,moduleDef * mod,classDef * scope,scopedNameDef * fqname,classTmplDef * tcd,templateDef * td,const char * pyname,int use_template_name,docstringDef * docstring)9276 static void instantiateClassTemplate(sipSpec *pt, moduleDef *mod,
9277 classDef *scope, scopedNameDef *fqname, classTmplDef *tcd,
9278 templateDef *td, const char *pyname, int use_template_name,
9279 docstringDef *docstring)
9280 {
9281 scopedNameDef *type_names, *type_values;
9282 classDef *cd;
9283 ctorDef *oct, **cttail;
9284 argDef *ad;
9285 ifaceFileList *iffl, **used;
9286 classList *cl;
9287 stringList *sl;
9288
9289 type_names = type_values = NULL;
9290 appendTypeStrings(classFQCName(tcd->cd), &tcd->sig, &td->types, NULL, &type_names, &type_values);
9291
9292 /*
9293 * Add a mapping from the template name to the instantiated name. If we
9294 * have got this far we know there is room for it.
9295 */
9296 ad = &tcd->sig.args[tcd->sig.nrArgs++];
9297 memset(ad, 0, sizeof (argDef));
9298 ad->atype = defined_type;
9299 ad->u.snd = classFQCName(tcd->cd);
9300
9301 appendScopedName(&type_names, text2scopePart(scopedNameTail(classFQCName(tcd->cd))));
9302 appendScopedName(&type_values, text2scopePart(scopedNameToString(fqname)));
9303
9304 /* Create the new class. */
9305 cd = sipMalloc(sizeof (classDef));
9306
9307 /* Start with a shallow copy. */
9308 *cd = *tcd->cd;
9309
9310 if (docstring != NULL)
9311 cd->docstring = docstring;
9312
9313 resetIsTemplateClass(cd);
9314 cd->pyname = cacheName(pt, pyname);
9315 cd->td = td;
9316
9317 if (use_template_name)
9318 setUseTemplateName(cd);
9319
9320 /* Handle the interface file. */
9321 cd->iff = findIfaceFile(pt, mod, fqname, class_iface,
9322 (scope != NULL ? scope->iff->api_range : NULL), NULL);
9323 cd->iff->module = mod;
9324
9325 appendCodeBlockList(&cd->iff->hdrcode, tcd->cd->iff->hdrcode);
9326
9327 /* Make a copy of the used list and add the enclosing scope. */
9328 used = &cd->iff->used;
9329
9330 for (iffl = tcd->cd->iff->used; iffl != NULL; iffl = iffl->next)
9331 appendToIfaceFileList(used, iffl->iff);
9332
9333 /* Include any scope header code. */
9334 if (scope != NULL)
9335 appendCodeBlockList(&cd->iff->hdrcode, scope->iff->hdrcode);
9336
9337 if (inMainModule())
9338 {
9339 setIsUsedName(cd->iff->name);
9340 setIsUsedName(cd->pyname);
9341 }
9342
9343 cd->ecd = currentScope();
9344
9345 /* Handle any type hints. */
9346 if (cd->typehint_in != NULL)
9347 cd->typehint_in = newTypeHint(
9348 templateString(cd->typehint_in->raw_hint, type_names,
9349 type_values));
9350
9351 if (cd->typehint_out != NULL)
9352 cd->typehint_out = newTypeHint(
9353 templateString(cd->typehint_out->raw_hint, type_names,
9354 type_values));
9355
9356 /* Handle any flagged enums. */
9357 if ((sl = cd->pyqt_flags_enums) != NULL)
9358 {
9359 cd->pyqt_flags_enums = NULL;
9360
9361 do
9362 {
9363 appendString(&cd->pyqt_flags_enums,
9364 templateString(sl->s, type_names, type_values));
9365 sl = sl->next;
9366 }
9367 while (sl != NULL);
9368 }
9369
9370 /* Handle the super-classes. */
9371 for (cl = cd->supers; cl != NULL; cl = cl->next)
9372 {
9373 int a;
9374 scopedNameDef *unscoped;
9375
9376 unscoped = removeGlobalScope(cl->cd->iff->fqcname);
9377
9378 /* Ignore defined or scoped classes. */
9379 if (cl->cd->iff->module != NULL || unscoped->next != NULL)
9380 continue;
9381
9382 for (a = 0; a < tcd->sig.nrArgs - 1; ++a)
9383 if (strcmp(unscoped->name, scopedNameTail(tcd->sig.args[a].u.snd)) == 0)
9384 {
9385 argDef *tad = &td->types.args[a];
9386 classDef *icd;
9387
9388 if (tad->atype == defined_type)
9389 icd = findClass(pt, class_iface, NULL, tad->u.snd, FALSE);
9390 else if (tad->atype == class_type)
9391 icd = tad->u.cd;
9392 else
9393 fatal("Template argument %s must expand to a class\n",
9394 unscoped->name);
9395
9396 cl->cd = icd;
9397 }
9398 }
9399
9400 /* Handle the enums. */
9401 instantiateTemplateEnums(pt, tcd, td, cd, used, type_names, type_values);
9402
9403 /* Handle the variables. */
9404 instantiateTemplateVars(pt, tcd, td, cd, used, type_names, type_values);
9405
9406 /* Handle the typedefs. */
9407 instantiateTemplateTypedefs(pt, tcd, td, cd, type_names, type_values);
9408
9409 /* Handle the ctors. */
9410 cd->ctors = NULL;
9411 cttail = &cd->ctors;
9412
9413 for (oct = tcd->cd->ctors; oct != NULL; oct = oct->next)
9414 {
9415 ctorDef *nct = sipMalloc(sizeof (ctorDef));
9416
9417 /* Start with a shallow copy. */
9418 *nct = *oct;
9419
9420 templateSignature(&nct->pysig, oct->kwargs, FALSE, tcd, td, cd,
9421 type_names, type_values);
9422
9423 if (oct->cppsig == NULL)
9424 nct->cppsig = NULL;
9425 else if (oct->cppsig == &oct->pysig)
9426 nct->cppsig = &nct->pysig;
9427 else
9428 {
9429 nct->cppsig = sipMalloc(sizeof (signatureDef));
9430
9431 *nct->cppsig = *oct->cppsig;
9432
9433 templateSignature(nct->cppsig, NoKwArgs, FALSE, tcd, td, cd,
9434 type_names, type_values);
9435 }
9436
9437 nct->methodcode = templateCode(pt, used, nct->methodcode, type_names, type_values);
9438 nct->premethodcode = templateCode(pt, used, nct->premethodcode, type_names, type_values);
9439
9440 nct->next = NULL;
9441 *cttail = nct;
9442 cttail = &nct->next;
9443
9444 /* Handle the default ctor. */
9445 if (tcd->cd->defctor == oct)
9446 cd->defctor = nct;
9447 }
9448
9449 cd->dealloccode = templateCode(pt, used, cd->dealloccode, type_names, type_values);
9450 cd->dtorcode = templateCode(pt, used, cd->dtorcode, type_names, type_values);
9451
9452 /* Handle the methods. */
9453 cd->members = instantiateTemplateMethods(tcd->cd->members, mod);
9454 cd->overs = instantiateTemplateOverloads(pt, tcd->cd->overs,
9455 tcd->cd->members, cd->members, tcd, td, cd, used, type_names,
9456 type_values);
9457
9458 cd->cppcode = templateCode(pt, used, cd->cppcode, type_names, type_values);
9459 cd->iff->hdrcode = templateCode(pt, used, cd->iff->hdrcode, type_names, type_values);
9460 cd->convtosubcode = templateCode(pt, used, cd->convtosubcode, type_names, type_values);
9461 cd->convtocode = templateCode(pt, used, cd->convtocode, type_names, type_values);
9462 cd->travcode = templateCode(pt, used, cd->travcode, type_names, type_values);
9463 cd->clearcode = templateCode(pt, used, cd->clearcode, type_names, type_values);
9464 cd->getbufcode = templateCode(pt, used, cd->getbufcode, type_names, type_values);
9465 cd->releasebufcode = templateCode(pt, used, cd->releasebufcode, type_names, type_values);
9466 cd->instancecode = templateCode(pt, used, cd->instancecode, type_names, type_values);
9467 cd->picklecode = templateCode(pt, used, cd->picklecode, type_names, type_values);
9468 cd->finalcode = templateCode(pt, used, cd->finalcode, type_names, type_values);
9469 cd->typehintcode = templateCode(pt, used, cd->typehintcode, type_names, type_values);
9470 cd->next = pt->classes;
9471
9472 pt->classes = cd;
9473
9474 tcd->sig.nrArgs--;
9475
9476 freeScopedName(type_names);
9477 freeScopedName(type_values);
9478 }
9479
9480
9481 /*
9482 * Instantiate the methods of a template class.
9483 */
instantiateTemplateMethods(memberDef * tmd,moduleDef * mod)9484 static memberDef *instantiateTemplateMethods(memberDef *tmd, moduleDef *mod)
9485 {
9486 memberDef *md, *methods, **mdtail;
9487
9488 methods = NULL;
9489 mdtail = &methods;
9490
9491 for (md = tmd; md != NULL; md = md->next)
9492 {
9493 memberDef *nmd = sipMalloc(sizeof (memberDef));
9494
9495 /* Start with a shallow copy. */
9496 *nmd = *md;
9497
9498 nmd->module = mod;
9499
9500 if (inMainModule())
9501 setIsUsedName(nmd->pyname);
9502
9503 nmd->next = NULL;
9504 *mdtail = nmd;
9505 mdtail = &nmd->next;
9506 }
9507
9508 return methods;
9509 }
9510
9511
9512 /*
9513 * Instantiate the overloads of a template class.
9514 */
instantiateTemplateOverloads(sipSpec * pt,overDef * tod,memberDef * tmethods,memberDef * methods,classTmplDef * tcd,templateDef * td,classDef * cd,ifaceFileList ** used,scopedNameDef * type_names,scopedNameDef * type_values)9515 static overDef *instantiateTemplateOverloads(sipSpec *pt, overDef *tod,
9516 memberDef *tmethods, memberDef *methods, classTmplDef *tcd,
9517 templateDef *td, classDef *cd, ifaceFileList **used,
9518 scopedNameDef *type_names, scopedNameDef *type_values)
9519 {
9520 overDef *od, *overloads, **odtail;
9521
9522 overloads = NULL;
9523 odtail = &overloads;
9524
9525 for (od = tod; od != NULL; od = od->next)
9526 {
9527 overDef *nod = sipMalloc(sizeof (overDef));
9528 memberDef *nmd, *omd;
9529
9530 /* Start with a shallow copy. */
9531 *nod = *od;
9532
9533 for (nmd = methods, omd = tmethods; omd != NULL; omd = omd->next, nmd = nmd->next)
9534 if (omd == od->common)
9535 {
9536 nod->common = nmd;
9537 break;
9538 }
9539
9540 templateSignature(&nod->pysig, od->kwargs, TRUE, tcd, td, cd,
9541 type_names, type_values);
9542
9543 if (od->cppsig == &od->pysig)
9544 nod->cppsig = &nod->pysig;
9545 else
9546 {
9547 nod->cppsig = sipMalloc(sizeof (signatureDef));
9548
9549 *nod->cppsig = *od->cppsig;
9550
9551 templateSignature(nod->cppsig, NoKwArgs, TRUE, tcd, td, cd,
9552 type_names, type_values);
9553 }
9554
9555 nod->methodcode = templateCode(pt, used, nod->methodcode, type_names, type_values);
9556 nod->premethodcode = templateCode(pt, used, nod->premethodcode, type_names, type_values);
9557 nod->virtcallcode = templateCode(pt, used, nod->virtcallcode, type_names, type_values);
9558 nod->virtcode = templateCode(pt, used, nod->virtcode, type_names, type_values);
9559
9560 nod->next = NULL;
9561 *odtail = nod;
9562 odtail = &nod->next;
9563 }
9564
9565 return overloads;
9566 }
9567
9568
9569 /*
9570 * Instantiate the enums of a template class.
9571 */
instantiateTemplateEnums(sipSpec * pt,classTmplDef * tcd,templateDef * td,classDef * cd,ifaceFileList ** used,scopedNameDef * type_names,scopedNameDef * type_values)9572 static void instantiateTemplateEnums(sipSpec *pt, classTmplDef *tcd,
9573 templateDef *td, classDef *cd, ifaceFileList **used,
9574 scopedNameDef *type_names, scopedNameDef *type_values)
9575 {
9576 enumDef *ted;
9577 moduleDef *mod = cd->iff->module;
9578
9579 for (ted = pt->enums; ted != NULL; ted = ted->next)
9580 if (ted->ecd == tcd->cd)
9581 {
9582 enumDef *ed;
9583 enumMemberDef *temd;
9584
9585 ed = sipMalloc(sizeof (enumDef));
9586
9587 /* Start with a shallow copy. */
9588 *ed = *ted;
9589
9590 if (ed->fqcname != NULL)
9591 {
9592 ed->fqcname = text2scopedName(cd->iff,
9593 scopedNameTail(ed->fqcname));
9594 ed->cname = cacheName(pt, scopedNameToString(ed->fqcname));
9595 }
9596
9597 if (inMainModule())
9598 {
9599 if (ed->pyname != NULL)
9600 setIsUsedName(ed->pyname);
9601
9602 if (ed->cname != NULL)
9603 setIsUsedName(ed->cname);
9604 }
9605
9606 ed->ecd = cd;
9607 ed->first_alt = ed;
9608 ed->module = mod;
9609 ed->members = NULL;
9610
9611 for (temd = ted->members; temd != NULL; temd = temd->next)
9612 {
9613 enumMemberDef *emd;
9614
9615 emd = sipMalloc(sizeof (enumMemberDef));
9616
9617 /* Start with a shallow copy. */
9618 *emd = *temd;
9619 emd->ed = ed;
9620
9621 emd->next = ed->members;
9622 ed->members = emd;
9623 }
9624
9625 ed->slots = instantiateTemplateMethods(ted->slots, mod);
9626 ed->overs = instantiateTemplateOverloads(pt, ted->overs,
9627 ted->slots, ed->slots, tcd, td, cd, used, type_names,
9628 type_values);
9629
9630 ed->next = pt->enums;
9631 pt->enums = ed;
9632 }
9633 }
9634
9635
9636 /*
9637 * Instantiate the variables of a template class.
9638 */
instantiateTemplateVars(sipSpec * pt,classTmplDef * tcd,templateDef * td,classDef * cd,ifaceFileList ** used,scopedNameDef * type_names,scopedNameDef * type_values)9639 static void instantiateTemplateVars(sipSpec *pt, classTmplDef *tcd,
9640 templateDef *td, classDef *cd, ifaceFileList **used,
9641 scopedNameDef *type_names, scopedNameDef *type_values)
9642 {
9643 varDef *tvd;
9644
9645 for (tvd = pt->vars; tvd != NULL; tvd = tvd->next)
9646 if (tvd->ecd == tcd->cd)
9647 {
9648 varDef *vd;
9649
9650 vd = sipMalloc(sizeof (varDef));
9651
9652 /* Start with a shallow copy. */
9653 *vd = *tvd;
9654
9655 if (inMainModule())
9656 setIsUsedName(vd->pyname);
9657
9658 vd->fqcname = text2scopedName(cd->iff,
9659 scopedNameTail(vd->fqcname));
9660 vd->ecd = cd;
9661 vd->module = cd->iff->module;
9662
9663 templateType(&vd->type, tcd, td, cd, type_names, type_values);
9664
9665 vd->accessfunc = templateCode(pt, used, vd->accessfunc, type_names, type_values);
9666 vd->getcode = templateCode(pt, used, vd->getcode, type_names, type_values);
9667 vd->setcode = templateCode(pt, used, vd->setcode, type_names, type_values);
9668
9669 addVariable(pt, vd);
9670 }
9671 }
9672
9673
9674 /*
9675 * Instantiate the typedefs of a template class.
9676 */
instantiateTemplateTypedefs(sipSpec * pt,classTmplDef * tcd,templateDef * td,classDef * cd,scopedNameDef * type_names,scopedNameDef * type_values)9677 static void instantiateTemplateTypedefs(sipSpec *pt, classTmplDef *tcd,
9678 templateDef *td, classDef *cd, scopedNameDef *type_names,
9679 scopedNameDef *type_values)
9680 {
9681 typedefDef *tdd;
9682
9683 for (tdd = pt->typedefs; tdd != NULL; tdd = tdd->next)
9684 {
9685 typedefDef *new_tdd;
9686
9687 if (tdd->ecd != tcd->cd)
9688 continue;
9689
9690 new_tdd = sipMalloc(sizeof (typedefDef));
9691
9692 /* Start with a shallow copy. */
9693 *new_tdd = *tdd;
9694
9695 new_tdd->fqname = text2scopedName(cd->iff,
9696 scopedNameTail(new_tdd->fqname));
9697 new_tdd->ecd = cd;
9698 new_tdd->module = cd->iff->module;
9699
9700 templateType(&new_tdd->type, tcd, td, cd, type_names, type_values);
9701
9702 addTypedef(pt, new_tdd);
9703 }
9704 }
9705
9706
9707 /*
9708 * Replace any template arguments in a signature.
9709 */
templateSignature(signatureDef * sd,KwArgs kwargs,int result,classTmplDef * tcd,templateDef * td,classDef * ncd,scopedNameDef * type_names,scopedNameDef * type_values)9710 static void templateSignature(signatureDef *sd, KwArgs kwargs, int result,
9711 classTmplDef *tcd, templateDef *td, classDef *ncd,
9712 scopedNameDef *type_names, scopedNameDef *type_values)
9713 {
9714 int a;
9715
9716 if (result)
9717 templateType(&sd->result, tcd, td, ncd, type_names, type_values);
9718
9719 for (a = 0; a < sd->nrArgs; ++a)
9720 {
9721 argDef *ad = &sd->args[a];
9722
9723 templateType(ad, tcd, td, ncd, type_names, type_values);
9724
9725 /* Make sure we have the name of any keyword argument. */
9726 if (inMainModule() && ad->name != NULL)
9727 {
9728 if (kwargs == AllKwArgs || (kwargs == OptionalKwArgs && ad->defval != NULL))
9729 setIsUsedName(ad->name);
9730 }
9731 }
9732 }
9733
9734
9735 /*
9736 * Replace any template arguments in a type.
9737 */
templateType(argDef * ad,classTmplDef * tcd,templateDef * td,classDef * ncd,scopedNameDef * type_names,scopedNameDef * type_values)9738 static void templateType(argDef *ad, classTmplDef *tcd, templateDef *td,
9739 classDef *ncd, scopedNameDef *type_names, scopedNameDef *type_values)
9740 {
9741 int a;
9742 char *name;
9743
9744 /* Descend into any sub-templates. */
9745 if (ad->atype == template_type)
9746 {
9747 templateDef *new_td = sipMalloc(sizeof (templateDef));
9748
9749 /* Make a deep copy of the template definition. */
9750 *new_td = *ad->u.td;
9751 ad->u.td = new_td;
9752
9753 templateSignature(&ad->u.td->types, NoKwArgs, FALSE, tcd, td, ncd,
9754 type_names, type_values);
9755
9756 return;
9757 }
9758
9759 /* Handle any default value. */
9760 if (ad->defval != NULL && ad->defval->vtype == fcall_value)
9761 {
9762 /*
9763 * We only handle the subset where the value is an function call, ie. a
9764 * template ctor.
9765 */
9766 valueDef *vd = ad->defval;
9767
9768 if (vd->vtype == fcall_value && vd->u.fcd->type.atype == defined_type)
9769 {
9770 valueDef *new_vd;
9771 fcallDef *fcd;
9772 scopedNameDef *snd, **tailp;
9773
9774 fcd = sipMalloc(sizeof (fcallDef));
9775 *fcd = *vd->u.fcd;
9776
9777 tailp = &fcd->type.u.snd;
9778 for (snd = vd->u.fcd->type.u.snd; snd != NULL; snd = snd->next)
9779 {
9780 *tailp = text2scopePart(
9781 templateString(snd->name, type_names, type_values));
9782 tailp = &(*tailp)->next;
9783 }
9784
9785 new_vd = sipMalloc(sizeof (valueDef));
9786 new_vd->vtype = fcall_value;
9787 new_vd->u.fcd = fcd;
9788
9789 ad->defval = new_vd;
9790 }
9791 }
9792
9793 /* Handle any type hints. */
9794 if (ad->typehint_in != NULL)
9795 ad->typehint_in = newTypeHint(
9796 templateString(ad->typehint_in->raw_hint, type_names,
9797 type_values));
9798
9799 if (ad->typehint_out != NULL)
9800 ad->typehint_out = newTypeHint(
9801 templateString(ad->typehint_out->raw_hint, type_names,
9802 type_values));
9803
9804 /* Ignore if it isn't an unscoped name. */
9805 if (ad->atype != defined_type || ad->u.snd->next != NULL)
9806 return;
9807
9808 name = ad->u.snd->name;
9809
9810 for (a = 0; a < tcd->sig.nrArgs - 1; ++a)
9811 if (strcmp(name, scopedNameTail(tcd->sig.args[a].u.snd)) == 0)
9812 {
9813 argDef *tad = &td->types.args[a];
9814
9815 ad->atype = tad->atype;
9816
9817 /* We take the constrained flag from the real type. */
9818 resetIsConstrained(ad);
9819
9820 if (isConstrained(tad))
9821 setIsConstrained(ad);
9822
9823 ad->u = tad->u;
9824
9825 return;
9826 }
9827
9828 /* Handle the class name itself. */
9829 if (strcmp(name, scopedNameTail(classFQCName(tcd->cd))) == 0)
9830 {
9831 ad->atype = class_type;
9832 ad->u.cd = ncd;
9833 ad->original_type = NULL;
9834 }
9835 }
9836
9837
9838 /*
9839 * Replace any template arguments in a literal code block.
9840 */
templateCode(sipSpec * pt,ifaceFileList ** used,codeBlockList * ocbl,scopedNameDef * names,scopedNameDef * values)9841 codeBlockList *templateCode(sipSpec *pt, ifaceFileList **used,
9842 codeBlockList *ocbl, scopedNameDef *names, scopedNameDef *values)
9843 {
9844 codeBlockList *ncbl = NULL;
9845
9846 while (ocbl != NULL)
9847 {
9848 char *at = ocbl->block->frag;
9849 int start_of_line = TRUE;
9850
9851 do
9852 {
9853 char *from = at, *first = NULL;
9854 codeBlock *cb;
9855 scopedNameDef *nam, *val, *nam_first, *val_first;
9856
9857 /* Suppress a compiler warning. */
9858 val_first = NULL;
9859
9860 /*
9861 * Don't do any substitution in lines that appear to be
9862 * preprocessor directives. This prevents #include'd file names
9863 * being broken.
9864 */
9865 if (start_of_line)
9866 {
9867 /* Strip leading whitespace. */
9868 while (isspace(*from))
9869 ++from;
9870
9871 if (*from == '#')
9872 {
9873 /* Skip to the end of the line. */
9874 do
9875 ++from;
9876 while (*from != '\n' && *from != '\0');
9877 }
9878 else
9879 {
9880 start_of_line = FALSE;
9881 }
9882 }
9883
9884 /*
9885 * Go through the rest of this fragment looking for each of the
9886 * types and the name of the class itself.
9887 */
9888 nam = names;
9889 val = values;
9890
9891 while (nam != NULL && val != NULL)
9892 {
9893 char *cp;
9894
9895 if ((cp = strstr(from, nam->name)) != NULL)
9896 if (first == NULL || first > cp)
9897 {
9898 nam_first = nam;
9899 val_first = val;
9900 first = cp;
9901 }
9902
9903 nam = nam->next;
9904 val = val->next;
9905 }
9906
9907 /* Create the new fragment. */
9908 cb = sipMalloc(sizeof (codeBlock));
9909
9910 if (at == ocbl->block->frag)
9911 {
9912 cb->filename = ocbl->block->filename;
9913 cb->linenr = ocbl->block->linenr;
9914 }
9915 else
9916 cb->filename = NULL;
9917
9918 appendCodeBlock(&ncbl, cb);
9919
9920 /* See if anything was found. */
9921 if (first == NULL)
9922 {
9923 /* We can just point to this. */
9924 cb->frag = at;
9925
9926 /* All done with this one. */
9927 at = NULL;
9928 }
9929 else
9930 {
9931 static char *gen_names[] = {
9932 "sipType_",
9933 "sipException_",
9934 NULL
9935 };
9936
9937 char *dp, *sp, **gn;
9938 int genname = FALSE;
9939
9940 /*
9941 * If the context in which the text is used is in the name of a
9942 * SIP generated object then translate any "::" scoping to "_"
9943 * and remove any const.
9944 */
9945 for (gn = gen_names; *gn != NULL; ++gn)
9946 if (search_back(first, at, *gn))
9947 {
9948 addUsedFromCode(pt, used, val_first->name);
9949 genname = TRUE;
9950 break;
9951 }
9952
9953 /* Fragment the fragment. */
9954 cb->frag = sipMalloc(first - at + strlen(val_first->name) + 1);
9955
9956 strncpy(cb->frag, at, first - at);
9957
9958 dp = &cb->frag[first - at];
9959 sp = val_first->name;
9960
9961 if (genname)
9962 {
9963 char gch;
9964
9965 if (strlen(sp) > 6 && strncmp(sp, "const ", 6) == 0)
9966 sp += 6;
9967
9968 while ((gch = *sp++) != '\0')
9969 if (gch == ':' && *sp == ':')
9970 {
9971 *dp++ = '_';
9972 ++sp;
9973 }
9974 else
9975 *dp++ = gch;
9976
9977 *dp = '\0';
9978 }
9979 else
9980 strcpy(dp, sp);
9981
9982 /* Move past the replaced text. */
9983 at = first + strlen(nam_first->name);
9984
9985 if (*at == '\n')
9986 start_of_line = TRUE;
9987 }
9988 }
9989 while (at != NULL && *at != '\0');
9990
9991 ocbl = ocbl->next;
9992 }
9993
9994 return ncbl;
9995 }
9996
9997
9998 /*
9999 * Return TRUE if the text at the end of a string matches the target string.
10000 */
search_back(const char * end,const char * start,const char * target)10001 static int search_back(const char *end, const char *start, const char *target)
10002 {
10003 size_t tlen = strlen(target);
10004
10005 if (start + tlen >= end)
10006 return FALSE;
10007
10008 return (strncmp(end - tlen, target, tlen) == 0);
10009 }
10010
10011
10012 /*
10013 * Add any needed interface files based on handwritten code.
10014 */
addUsedFromCode(sipSpec * pt,ifaceFileList ** used,const char * sname)10015 static void addUsedFromCode(sipSpec *pt, ifaceFileList **used, const char *sname)
10016 {
10017 ifaceFileDef *iff;
10018 enumDef *ed;
10019
10020 for (iff = pt->ifacefiles; iff != NULL; iff = iff->next)
10021 {
10022 if (iff->type != class_iface && iff->type != exception_iface)
10023 continue;
10024
10025 if (sameName(iff->fqcname, sname))
10026 {
10027 appendToIfaceFileList(used, iff);
10028 return;
10029 }
10030 }
10031
10032 for (ed = pt->enums; ed != NULL; ed = ed->next)
10033 {
10034 if (ed->ecd == NULL)
10035 continue;
10036
10037 if (sameName(ed->fqcname, sname))
10038 {
10039 appendToIfaceFileList(used, ed->ecd->iff);
10040 return;
10041 }
10042 }
10043 }
10044
10045
10046 /*
10047 * Compare a scoped name with its string equivalent.
10048 */
sameName(scopedNameDef * snd,const char * sname)10049 static int sameName(scopedNameDef *snd, const char *sname)
10050 {
10051 /* Handle any explicit scopes. */
10052 if (sname[0] == ':' && sname[1] == ':')
10053 {
10054 if (snd->name[0] != '\0')
10055 return FALSE;
10056
10057 sname += 2;
10058 }
10059
10060 snd = removeGlobalScope(snd);
10061
10062 while (snd != NULL && *sname != '\0')
10063 {
10064 const char *sp = snd->name;
10065
10066 while (*sp != '\0' && *sname != ':' && *sname != '\0')
10067 if (*sp++ != *sname++)
10068 return FALSE;
10069
10070 if (*sp != '\0' || (*sname != ':' && *sname != '\0'))
10071 return FALSE;
10072
10073 snd = snd->next;
10074
10075 if (*sname == ':')
10076 sname += 2;
10077 }
10078
10079 return (snd == NULL && *sname == '\0');
10080 }
10081
10082
10083 /*
10084 * Compare a (possibly) relative scoped name with a fully qualified scoped name
10085 * while taking the current scope into account.
10086 */
foundInScope(scopedNameDef * fq_name,scopedNameDef * rel_name)10087 static int foundInScope(scopedNameDef *fq_name, scopedNameDef *rel_name)
10088 {
10089 classDef *scope;
10090
10091 for (scope = currentScope(); scope != NULL; scope = scope->ecd)
10092 {
10093 scopedNameDef *snd;
10094 int found;
10095
10096 snd = copyScopedName(classFQCName(scope));
10097 appendScopedName(&snd, copyScopedName(rel_name));
10098
10099 found = (compareScopedNames(fq_name, snd) == 0);
10100
10101 freeScopedName(snd);
10102
10103 if (found)
10104 return TRUE;
10105 }
10106
10107 return compareScopedNames(fq_name, rel_name) == 0;
10108 }
10109
10110
10111 /*
10112 * Create a new typedef.
10113 */
newTypedef(sipSpec * pt,moduleDef * mod,char * name,argDef * type,optFlags * optflgs,docstringDef * docstring)10114 static void newTypedef(sipSpec *pt, moduleDef *mod, char *name, argDef *type,
10115 optFlags *optflgs, docstringDef *docstring)
10116 {
10117 int no_type_name;
10118 typedefDef *td;
10119 scopedNameDef *fqname;
10120 classDef *scope;
10121
10122 scope = currentScope();
10123 fqname = text2scopedName((scope != NULL ? scope->iff : NULL), name);
10124 no_type_name = (getOptFlag(optflgs, "NoTypeName", bool_flag) != NULL);
10125
10126 /* See if we are instantiating a template class. */
10127 if (type->atype == template_type)
10128 {
10129 classTmplDef *tcd;
10130 templateDef *td = type->u.td;
10131
10132 for (tcd = pt->classtemplates; tcd != NULL; tcd = tcd->next)
10133 if (foundInScope(tcd->cd->iff->fqcname, td->fqname) &&
10134 sameTemplateSignature(&tcd->sig, &td->types, FALSE))
10135 {
10136 instantiateClassTemplate(pt, mod, scope, fqname, tcd, td,
10137 getPythonName(mod, optflgs, name), no_type_name,
10138 docstring);
10139
10140 /* All done. */
10141 return;
10142 }
10143 }
10144
10145 td = sipMalloc(sizeof (typedefDef));
10146
10147 td->tdflags = 0;
10148 td->fqname = fqname;
10149 td->ecd = scope;
10150 td->module = mod;
10151 td->platforms = currentPlatforms;
10152 td->type = *type;
10153
10154 if (getOptFlag(optflgs, "Capsule", bool_flag) != NULL)
10155 {
10156 /* Make sure the type is void *. */
10157 if (type->atype != void_type || type->nrderefs != 1 || isConstArg(type) || isReference(type))
10158 {
10159 fatalScopedName(fqname);
10160 fatal(" must be a void* if /Capsule/ is specified\n");
10161 }
10162
10163 td->type.atype = capsule_type;
10164 td->type.nrderefs = 0;
10165 td->type.u.cap = fqname;
10166 }
10167
10168 if (no_type_name)
10169 setNoTypeName(td);
10170
10171 addTypedef(pt, td);
10172 }
10173
10174
10175 /*
10176 * Add a typedef to the list so that the list remains sorted.
10177 */
addTypedef(sipSpec * pt,typedefDef * tdd)10178 static void addTypedef(sipSpec *pt, typedefDef *tdd)
10179 {
10180 typedefDef **tdp;
10181
10182 /*
10183 * Check it doesn't already exist (with a strict parse) and find the
10184 * position in the sorted list where it should be put.
10185 */
10186 for (tdp = &pt->typedefs; *tdp != NULL; tdp = &(*tdp)->next)
10187 {
10188 int res = compareScopedNames((*tdp)->fqname, tdd->fqname);
10189
10190 if (res == 0 && strictParse)
10191 {
10192 fatalScopedName(tdd->fqname);
10193 fatal(" already defined\n");
10194 }
10195
10196 if (res >= 0)
10197 break;
10198 }
10199
10200 tdd->next = *tdp;
10201 *tdp = tdd;
10202
10203 tdd->module->nrtypedefs++;
10204 }
10205
10206
10207 /*
10208 * Speculatively try and resolve any typedefs. In some cases (eg. when
10209 * comparing template signatures) it helps to use the real type if it is known.
10210 * Note that this wouldn't be necessary if we required that all types be known
10211 * before they are used.
10212 */
resolveAnyTypedef(sipSpec * pt,argDef * ad)10213 static void resolveAnyTypedef(sipSpec *pt, argDef *ad)
10214 {
10215 argDef orig = *ad;
10216
10217 while (ad->atype == defined_type)
10218 {
10219 ad->atype = no_type;
10220 searchTypedefs(pt, ad->u.snd, ad);
10221
10222 /*
10223 * Don't resolve to a template type as it may be superceded later on
10224 * by a more specific mapped type.
10225 */
10226 if (ad->atype == no_type || ad->atype == template_type)
10227 {
10228 *ad = orig;
10229 break;
10230 }
10231 }
10232 }
10233
10234
10235 /*
10236 * Return TRUE if the template signatures are the same. A deep comparison is
10237 * used for mapped type templates where we want to recurse into any nested
10238 * templates.
10239 */
sameTemplateSignature(signatureDef * tmpl_sd,signatureDef * args_sd,int deep)10240 int sameTemplateSignature(signatureDef *tmpl_sd, signatureDef *args_sd,
10241 int deep)
10242 {
10243 int a;
10244
10245 if (tmpl_sd->nrArgs != args_sd->nrArgs)
10246 return FALSE;
10247
10248 for (a = 0; a < tmpl_sd->nrArgs; ++a)
10249 {
10250 argDef *tmpl_ad = &tmpl_sd->args[a];
10251 argDef *args_ad = &args_sd->args[a];
10252
10253 /*
10254 * If we are doing a shallow comparision (ie. for class templates) then
10255 * a type name in the template signature matches anything in the
10256 * argument signature.
10257 */
10258 if (tmpl_ad->atype == defined_type && !deep)
10259 continue;
10260
10261 /*
10262 * For type names only compare the references and pointers, and do the
10263 * same for any nested templates.
10264 */
10265 if (tmpl_ad->atype == defined_type && args_ad->atype == defined_type)
10266 {
10267 if (isReference(tmpl_ad) != isReference(args_ad) || tmpl_ad->nrderefs != args_ad->nrderefs)
10268 return FALSE;
10269 }
10270 else if (tmpl_ad->atype == template_type && args_ad->atype == template_type)
10271 {
10272 if (!sameTemplateSignature(&tmpl_ad->u.td->types, &args_ad->u.td->types, deep))
10273 return FALSE;
10274 }
10275 else if (!sameBaseType(tmpl_ad, args_ad))
10276 return FALSE;
10277 }
10278
10279 return TRUE;
10280 }
10281
10282
10283 /*
10284 * Create a new variable.
10285 */
newVar(sipSpec * pt,moduleDef * mod,char * name,int isstatic,argDef * type,optFlags * of,codeBlock * acode,codeBlock * gcode,codeBlock * scode,int section)10286 static void newVar(sipSpec *pt, moduleDef *mod, char *name, int isstatic,
10287 argDef *type, optFlags *of, codeBlock *acode, codeBlock *gcode,
10288 codeBlock *scode, int section)
10289 {
10290 varDef *var;
10291 classDef *escope = currentScope();
10292 nameDef *nd;
10293
10294 /*
10295 * For the moment we don't support capsule variables because it needs the
10296 * API major version increasing.
10297 */
10298 if (type->atype == capsule_type)
10299 yyerror("Capsule variables not yet supported");
10300
10301 /* Check the section. */
10302 if (section != 0)
10303 {
10304 if ((section & SECT_IS_PUBLIC) == 0)
10305 yyerror("Class variables must be in the public section");
10306
10307 if (!isstatic && acode != NULL)
10308 yyerror("%AccessCode cannot be specified for non-static class variables");
10309 }
10310
10311 if (isstatic && pt->genc)
10312 yyerror("Cannot have static members in a C structure");
10313
10314 if (gcode != NULL || scode != NULL)
10315 {
10316 if (acode != NULL)
10317 yyerror("Cannot mix %AccessCode and %GetCode or %SetCode");
10318
10319 if (escope == NULL)
10320 yyerror("Cannot specify %GetCode or %SetCode for global variables");
10321 }
10322
10323 applyTypeFlags(mod, type, of);
10324
10325 nd = cacheName(pt, getPythonName(mod, of, name));
10326
10327 if (inMainModule())
10328 setIsUsedName(nd);
10329
10330 checkAttributes(pt, mod, escope, NULL, nd->text, FALSE);
10331
10332 var = sipMalloc(sizeof (varDef));
10333
10334 var->pyname = nd;
10335 var->fqcname = text2scopedName((escope != NULL ? escope->iff : NULL),
10336 name);
10337 var->ecd = escope;
10338 var->module = mod;
10339 var->varflags = 0;
10340 var->no_typehint = getNoTypeHint(of);
10341 var->platforms = currentPlatforms;
10342 var->type = *type;
10343 appendCodeBlock(&var->accessfunc, acode);
10344 appendCodeBlock(&var->getcode, gcode);
10345 appendCodeBlock(&var->setcode, scode);
10346
10347 if (isstatic || (escope != NULL && escope->iff->type == namespace_iface))
10348 setIsStaticVar(var);
10349
10350 if (getOptFlag(of, "NoSetter", bool_flag) != NULL)
10351 setNoSetter(var);
10352
10353 addVariable(pt, var);
10354 }
10355
10356
10357 /*
10358 * Create a new ctor.
10359 */
newCtor(moduleDef * mod,char * name,int sectFlags,signatureDef * args,optFlags * optflgs,codeBlock * methodcode,throwArgs * exceptions,signatureDef * cppsig,int explicit,docstringDef * docstring,codeBlock * premethodcode)10360 static void newCtor(moduleDef *mod, char *name, int sectFlags,
10361 signatureDef *args, optFlags *optflgs, codeBlock *methodcode,
10362 throwArgs *exceptions, signatureDef *cppsig, int explicit,
10363 docstringDef *docstring, codeBlock *premethodcode)
10364 {
10365 int a;
10366 ctorDef *ct, **ctp;
10367 classDef *cd = currentScope();
10368
10369 /* Check the name of the constructor. */
10370 if (strcmp(classBaseName(cd), name) != 0)
10371 yyerror("Constructor doesn't have the same name as its class");
10372
10373 /* Add to the list of constructors. */
10374 ct = sipMalloc(sizeof (ctorDef));
10375
10376 if (sectFlags & SECT_IS_PROT && makeProtPublic)
10377 {
10378 sectFlags &= ~SECT_IS_PROT;
10379 sectFlags |= SECT_IS_PUBLIC;
10380 }
10381
10382 /* Allow the signature to be used like an function signature. */
10383 memset(&args->result, 0, sizeof (argDef));
10384 args->result.atype = void_type;
10385
10386 ct->docstring = docstring;
10387 ct->ctorflags = sectFlags;
10388 ct->no_typehint = getNoTypeHint(optflgs);
10389 ct->api_range = getAPIRange(optflgs);
10390 ct->pysig = *args;
10391 ct->cppsig = (cppsig != NULL ? cppsig : &ct->pysig);
10392 ct->exceptions = exceptions;
10393 ct->platforms = currentPlatforms;
10394 appendCodeBlock(&ct->methodcode, methodcode);
10395 appendCodeBlock(&ct->premethodcode, premethodcode);
10396
10397 if (!isPrivateCtor(ct))
10398 setCanCreate(cd);
10399
10400 if (isProtectedCtor(ct))
10401 setNeedsShadow(cd);
10402
10403 if (explicit)
10404 setIsExplicitCtor(ct);
10405
10406 getHooks(optflgs, &ct->prehook, &ct->posthook);
10407
10408 if (getReleaseGIL(optflgs))
10409 setIsReleaseGILCtor(ct);
10410 else if (getHoldGIL(optflgs))
10411 setIsHoldGILCtor(ct);
10412
10413 if (getTransfer(optflgs))
10414 setIsResultTransferredCtor(ct);
10415
10416 if (getDeprecated(optflgs))
10417 setIsDeprecatedCtor(ct);
10418
10419 if (!isPrivateCtor(ct))
10420 ct->kwargs = keywordArgs(mod, optflgs, &ct->pysig, FALSE);
10421
10422 if (methodcode == NULL && getOptFlag(optflgs, "NoRaisesPyException", bool_flag) == NULL)
10423 {
10424 if (allRaisePyException(mod) || getOptFlag(optflgs, "RaisesPyException", bool_flag) != NULL)
10425 setRaisesPyExceptionCtor(ct);
10426 }
10427
10428 if (getOptFlag(optflgs, "NoDerived", bool_flag) != NULL)
10429 {
10430 if (cppsig != NULL)
10431 yyerror("The /NoDerived/ annotation cannot be used with a C++ signature");
10432
10433 if (methodcode == NULL)
10434 yyerror("The /NoDerived/ annotation must be used with %MethodCode");
10435
10436 ct->cppsig = NULL;
10437 }
10438
10439 if (getOptFlag(optflgs, "Default", bool_flag) != NULL)
10440 {
10441 if (cd->defctor != NULL)
10442 yyerror("A constructor with the /Default/ annotation has already been defined");
10443
10444 cd->defctor = ct;
10445 }
10446
10447 /* /Transfer/ arguments need the wrapper. */
10448 for (a = 0; a < ct->pysig.nrArgs; ++a)
10449 {
10450 argDef *ad = &ct->pysig.args[a];
10451
10452 if (isTransferred(ad))
10453 setGetWrapper(ad);
10454 }
10455
10456 /* Append to the list. */
10457 for (ctp = &cd->ctors; *ctp != NULL; ctp = &(*ctp)->next)
10458 ;
10459
10460 *ctp = ct;
10461 }
10462
10463
10464 /*
10465 * Create a new function.
10466 */
newFunction(sipSpec * pt,moduleDef * mod,classDef * c_scope,ifaceFileDef * ns_scope,mappedTypeDef * mt_scope,int sflags,int isstatic,int issignal,int isslot,int isvirt,char * name,signatureDef * sig,int isconst,int isabstract,optFlags * optflgs,codeBlock * methodcode,codeBlock * vcode,codeBlock * virtcallcode,throwArgs * exceptions,signatureDef * cppsig,docstringDef * docstring,int isfinal,codeBlock * premethodcode)10467 static void newFunction(sipSpec *pt, moduleDef *mod, classDef *c_scope,
10468 ifaceFileDef *ns_scope, mappedTypeDef *mt_scope, int sflags,
10469 int isstatic, int issignal, int isslot, int isvirt, char *name,
10470 signatureDef *sig, int isconst, int isabstract, optFlags *optflgs,
10471 codeBlock *methodcode, codeBlock *vcode, codeBlock *virtcallcode,
10472 throwArgs *exceptions, signatureDef *cppsig, docstringDef *docstring,
10473 int isfinal, codeBlock *premethodcode)
10474 {
10475 static const char *annos[] = {
10476 "__len__",
10477 "__imatmul__",
10478 "__matmul__",
10479 "AbortOnException",
10480 "AllowNone",
10481 "API",
10482 "AutoGen",
10483 "Deprecated",
10484 "DisallowNone",
10485 "Encoding",
10486 "Factory",
10487 "HoldGIL",
10488 "KeywordArgs",
10489 "KeepReference",
10490 "NewThread",
10491 "NoArgParser",
10492 "NoCopy",
10493 "NoRaisesPyException",
10494 "NoTypeHint",
10495 "NoVirtualErrorHandler",
10496 "Numeric",
10497 "PostHook",
10498 "PreHook",
10499 "PyInt",
10500 "PyName",
10501 "PyQtSignalHack",
10502 "RaisesPyException",
10503 "ReleaseGIL",
10504 "Sequence",
10505 "VirtualErrorHandler",
10506 "Transfer",
10507 "TransferBack",
10508 "TransferThis",
10509 "TypeHint",
10510 NULL
10511 };
10512
10513 const char *pyname, *virt_error_handler;
10514 int factory, xferback, no_arg_parser, no_virt_error_handler;
10515 overDef *od, **odp, **headp;
10516 optFlag *of;
10517
10518 checkAnnos(optflgs, annos);
10519
10520 /* Extra checks for a C module. */
10521 if (pt->genc)
10522 {
10523 if (c_scope != NULL)
10524 yyerror("Function declaration not allowed in a struct in a C module");
10525
10526 if (isstatic)
10527 yyerror("Static functions not allowed in a C module");
10528
10529 if (exceptions != NULL)
10530 yyerror("Exceptions not allowed in a C module");
10531
10532 /* Handle C void prototypes. */
10533 if (sig->nrArgs == 1)
10534 {
10535 argDef *vad = &sig->args[0];
10536
10537 if (vad->atype == void_type && vad->nrderefs == 0)
10538 sig->nrArgs = 0;
10539 }
10540 }
10541
10542 if (mt_scope != NULL)
10543 headp = &mt_scope->overs;
10544 else if (c_scope != NULL)
10545 headp = &c_scope->overs;
10546 else
10547 headp = &mod->overs;
10548
10549 /*
10550 * See if the function has a non-lazy method. These are methods that
10551 * Python expects to see defined in the type before any instance of the
10552 * type is created.
10553 */
10554 if (c_scope != NULL)
10555 {
10556 static const char *lazy[] = {
10557 "__getattribute__",
10558 "__getattr__",
10559 "__enter__",
10560 "__exit__",
10561 "__aenter__",
10562 "__aexit__",
10563 NULL
10564 };
10565
10566 const char **l;
10567
10568 for (l = lazy; *l != NULL; ++l)
10569 if (strcmp(name, *l) == 0)
10570 {
10571 setHasNonlazyMethod(c_scope);
10572 break;
10573 }
10574 }
10575
10576 /* See if it is a factory method. */
10577 if (getOptFlag(optflgs, "Factory", bool_flag) != NULL)
10578 factory = TRUE;
10579 else
10580 {
10581 int a;
10582
10583 factory = FALSE;
10584
10585 /* Check /TransferThis/ wasn't specified. */
10586 if (c_scope == NULL || isstatic)
10587 for (a = 0; a < sig->nrArgs; ++a)
10588 if (isThisTransferred(&sig->args[a]))
10589 yyerror("/TransferThis/ may only be specified in constructors and class methods");
10590 }
10591
10592 /* See if the result is to be returned to Python ownership. */
10593 xferback = (getOptFlag(optflgs, "TransferBack", bool_flag) != NULL);
10594
10595 if (factory && xferback)
10596 yyerror("/TransferBack/ and /Factory/ cannot both be specified");
10597
10598 /* Create a new overload definition. */
10599
10600 od = sipMalloc(sizeof (overDef));
10601
10602 getSourceLocation(&od->sloc);
10603
10604 /* Set the overload flags. */
10605
10606 if ((sflags & SECT_IS_PROT) && makeProtPublic)
10607 {
10608 sflags &= ~SECT_IS_PROT;
10609 sflags |= SECT_IS_PUBLIC | OVER_REALLY_PROT;
10610 }
10611
10612 od->overflags = sflags;
10613
10614 if (issignal)
10615 {
10616 resetIsSlot(od);
10617 setIsSignal(od);
10618 }
10619 else if (isslot)
10620 {
10621 resetIsSignal(od);
10622 setIsSlot(od);
10623 }
10624
10625 od->no_typehint = getNoTypeHint(optflgs);
10626
10627 if (isSignal(od))
10628 if ((of = getOptFlag(optflgs, "PyQtSignalHack", integer_flag)) != NULL)
10629 od->pyqt_signal_hack = of->fvalue.ival;
10630
10631 if (factory)
10632 setIsFactory(od);
10633
10634 if (xferback)
10635 setIsResultTransferredBack(od);
10636
10637 if (getTransfer(optflgs))
10638 setIsResultTransferred(od);
10639
10640 if (getOptFlag(optflgs, "TransferThis", bool_flag) != NULL)
10641 setIsThisTransferredMeth(od);
10642
10643 if (methodcode == NULL && getOptFlag(optflgs, "NoRaisesPyException", bool_flag) == NULL)
10644 {
10645 if (allRaisePyException(mod) || getOptFlag(optflgs, "RaisesPyException", bool_flag) != NULL)
10646 setRaisesPyException(od);
10647 }
10648
10649 if (isProtected(od))
10650 setNeedsShadow(c_scope);
10651
10652 if ((isSlot(od) || isSignal(od)) && !isPrivate(od))
10653 {
10654 if (isSignal(od))
10655 setNeedsShadow(c_scope);
10656
10657 pt->sigslots = TRUE;
10658 }
10659
10660 if (isSignal(od) && (methodcode != NULL || vcode != NULL || virtcallcode != NULL))
10661 yyerror("Cannot provide code for signals");
10662
10663 if (isstatic)
10664 {
10665 if (isSignal(od))
10666 yyerror("Static functions cannot be signals");
10667
10668 if (isvirt)
10669 yyerror("Static functions cannot be virtual");
10670
10671 setIsStatic(od);
10672 }
10673
10674 if (isconst)
10675 setIsConst(od);
10676
10677 if (isfinal)
10678 setIsFinal(od);
10679
10680 if (isabstract)
10681 {
10682 if (sflags == 0)
10683 yyerror("Non-class function specified as abstract");
10684
10685 setIsAbstract(od);
10686 }
10687
10688 if ((of = getOptFlag(optflgs, "AutoGen", opt_name_flag)) != NULL)
10689 {
10690 if (of->fvalue.sval == NULL || isEnabledFeature(of->fvalue.sval))
10691 setIsAutoGen(od);
10692 }
10693
10694 virt_error_handler = getVirtErrorHandler(optflgs);
10695 no_virt_error_handler = (getOptFlag(optflgs, "NoVirtualErrorHandler", bool_flag) != NULL);
10696
10697 if (isvirt)
10698 {
10699 if (!isfinal)
10700 {
10701 setIsVirtual(od);
10702 setNeedsShadow(c_scope);
10703 }
10704
10705 if (getOptFlag(optflgs, "AbortOnException", bool_flag) != NULL)
10706 setAbortOnException(od);
10707
10708 if (no_virt_error_handler)
10709 {
10710 if (virt_error_handler != NULL)
10711 yyerror("/VirtualErrorHandler/ and /NoVirtualErrorHandler/ provided");
10712
10713 setNoErrorHandler(od);
10714 }
10715 else
10716 {
10717 od->virt_error_handler = virt_error_handler;
10718 }
10719 }
10720 else
10721 {
10722 if (vcode != NULL)
10723 yyerror("%VirtualCatcherCode provided for non-virtual function");
10724
10725 if (virt_error_handler != NULL)
10726 yyerror("/VirtualErrorHandler/ provided for non-virtual function");
10727
10728 if (no_virt_error_handler)
10729 yyerror("/NoVirtualErrorHandler/ provided for non-virtual function");
10730 }
10731
10732 od->cppname = name;
10733 od->pysig = *sig;
10734 od->cppsig = (cppsig != NULL ? cppsig : &od->pysig);
10735 od->exceptions = exceptions;
10736 od->platforms = currentPlatforms;
10737 appendCodeBlock(&od->methodcode, methodcode);
10738 appendCodeBlock(&od->premethodcode, premethodcode);
10739 appendCodeBlock(&od->virtcallcode, virtcallcode);
10740 appendCodeBlock(&od->virtcode, vcode);
10741
10742 no_arg_parser = (getOptFlag(optflgs, "NoArgParser", bool_flag) != NULL);
10743
10744 if (no_arg_parser)
10745 {
10746 if (methodcode == NULL)
10747 yyerror("%MethodCode must be supplied if /NoArgParser/ is specified");
10748 }
10749 else
10750 {
10751 /*
10752 * The argument parser requires that there is nothing after an
10753 * ellipsis.
10754 */
10755 checkEllipsis(sig);
10756 }
10757
10758 if (cppsig != NULL)
10759 checkEllipsis(cppsig);
10760
10761 if (getOptFlag(optflgs, "NoCopy", bool_flag) != NULL)
10762 setNoCopy(&od->pysig.result);
10763
10764 if (getAllowNone(optflgs))
10765 setAllowNone(&od->pysig.result);
10766
10767 if (getDisallowNone(optflgs))
10768 setDisallowNone(&od->pysig.result);
10769
10770 handleKeepReference(optflgs, &od->pysig.result, mod);
10771
10772 pyname = getPythonName(mod, optflgs, name);
10773
10774 od->common = findFunction(pt, mod, c_scope, ns_scope, mt_scope, pyname,
10775 (methodcode != NULL), sig->nrArgs, no_arg_parser);
10776
10777 if (isProtected(od))
10778 setHasProtected(od->common);
10779
10780 if (strcmp(pyname, "__delattr__") == 0)
10781 setIsDelattr(od);
10782
10783 od->docstring = docstring;
10784
10785 od->api_range = getAPIRange(optflgs);
10786
10787 if (od->api_range == NULL)
10788 setNotVersioned(od->common);
10789
10790 if (getOptFlag(optflgs, "Numeric", bool_flag) != NULL)
10791 {
10792 if (isSequence(od->common))
10793 yyerror("/Sequence/ has already been specified");
10794
10795 setIsNumeric(od->common);
10796 }
10797
10798 if (getOptFlag(optflgs, "Sequence", bool_flag) != NULL)
10799 {
10800 if (isNumeric(od->common))
10801 yyerror("/Numeric/ has already been specified");
10802
10803 setIsSequence(od->common);
10804 }
10805
10806 /* Methods that run in new threads must be virtual. */
10807 if (getOptFlag(optflgs, "NewThread", bool_flag) != NULL)
10808 {
10809 argDef *res;
10810
10811 if (!isvirt)
10812 yyerror("/NewThread/ may only be specified for virtual functions");
10813
10814 /*
10815 * This is an arbitary limitation to make the code generator slightly
10816 * easier - laziness on my part.
10817 */
10818 res = &od->cppsig->result;
10819
10820 if (res->atype != void_type || res->nrderefs != 0)
10821 yyerror("/NewThread/ may only be specified for void functions");
10822
10823 setIsNewThread(od);
10824 }
10825
10826 getHooks(optflgs, &od->prehook, &od->posthook);
10827
10828 if (getReleaseGIL(optflgs))
10829 setIsReleaseGIL(od);
10830 else if (getHoldGIL(optflgs))
10831 setIsHoldGIL(od);
10832
10833 if (getDeprecated(optflgs))
10834 setIsDeprecated(od);
10835
10836 if (!isPrivate(od) && (od->common->slot == no_slot || od->common->slot == call_slot))
10837 {
10838 od->kwargs = keywordArgs(mod, optflgs, &od->pysig, hasProtected(od->common));
10839
10840 if (od->kwargs != NoKwArgs)
10841 setUseKeywordArgs(od->common);
10842
10843 /*
10844 * If the overload is protected and defined in an imported module then
10845 * we need to make sure that any other overloads' keyword argument
10846 * names are marked as used.
10847 */
10848 if (!isSignal(od) && isProtected(od) && !inMainModule())
10849 {
10850 overDef *kwod;
10851
10852 for (kwod = c_scope->overs; kwod != NULL; kwod = kwod->next)
10853 if (kwod->common == od->common && kwod->kwargs != NoKwArgs)
10854 {
10855 int a;
10856
10857 for (a = 0; a < kwod->pysig.nrArgs; ++a)
10858 {
10859 argDef *ad = &kwod->pysig.args[a];
10860
10861 if (kwod->kwargs == OptionalKwArgs && ad->defval == NULL)
10862 continue;
10863
10864 if (ad->name != NULL)
10865 setIsUsedName(ad->name);
10866 }
10867 }
10868 }
10869 }
10870
10871 od->next = NULL;
10872
10873 /* See if we want to auto-generate some methods. */
10874 if (getOptFlag(optflgs, "__len__", bool_flag) != NULL)
10875 {
10876 overDef *len;
10877
10878 len = sipMalloc(sizeof (overDef));
10879
10880 len->cppname = "__len__";
10881 len->overflags = SECT_IS_PUBLIC;
10882 len->pysig.result.atype = ssize_type;
10883 len->pysig.nrArgs = 0;
10884 len->cppsig = &len->pysig;
10885
10886 if ((len->methodcode = od->methodcode) == NULL)
10887 {
10888 char *buf = sipStrdup(" sipRes = (Py_ssize_t)sipCpp->");
10889 codeBlock *code;
10890
10891 append(&buf, od->cppname);
10892 append(&buf, "();\n");
10893
10894 code = sipMalloc(sizeof (codeBlock));
10895
10896 code->frag = buf;
10897 code->filename = "Auto-generated";
10898 code->linenr = 1;
10899
10900 appendCodeBlock(&len->methodcode, code);
10901 }
10902
10903 len->common = findFunction(pt, mod, c_scope, ns_scope, mt_scope,
10904 len->cppname, TRUE, 0, FALSE);
10905
10906 len->platforms = od->platforms;
10907 len->next = od->next;
10908 od->next = len;
10909 }
10910
10911 if (getOptFlag(optflgs, "__matmul__", bool_flag) != NULL)
10912 {
10913 overDef *matmul;
10914
10915 matmul = sipMalloc(sizeof (overDef));
10916
10917 matmul->cppname = "__matmul__";
10918 matmul->overflags = SECT_IS_PUBLIC;
10919 matmul->pysig = od->pysig;
10920 matmul->cppsig = (cppsig != NULL ? cppsig : &matmul->pysig);
10921
10922 matmul->methodcode = od->methodcode;
10923
10924 matmul->common = findFunction(pt, mod, c_scope, ns_scope, mt_scope,
10925 matmul->cppname, (matmul->methodcode != NULL),
10926 matmul->pysig.nrArgs, FALSE);
10927
10928 matmul->platforms = od->platforms;
10929 matmul->next = od->next;
10930 od->next = matmul;
10931 }
10932
10933 if (getOptFlag(optflgs, "__imatmul__", bool_flag) != NULL)
10934 {
10935 overDef *imatmul;
10936
10937 imatmul = sipMalloc(sizeof (overDef));
10938
10939 imatmul->cppname = "__imatmul__";
10940 imatmul->overflags = SECT_IS_PUBLIC;
10941 imatmul->pysig = od->pysig;
10942 imatmul->cppsig = (cppsig != NULL ? cppsig : &imatmul->pysig);
10943
10944 imatmul->methodcode = od->methodcode;
10945
10946 imatmul->common = findFunction(pt, mod, c_scope, ns_scope, mt_scope,
10947 imatmul->cppname, (imatmul->methodcode != NULL),
10948 imatmul->pysig.nrArgs, FALSE);
10949
10950 imatmul->platforms = od->platforms;
10951 imatmul->next = od->next;
10952 od->next = imatmul;
10953 }
10954
10955 /* Append to the list. */
10956 for (odp = headp; *odp != NULL; odp = &(*odp)->next)
10957 ;
10958
10959 *odp = od;
10960 }
10961
10962
10963 /*
10964 * Return the Python name based on the C/C++ name and any /PyName/ annotation.
10965 */
getPythonName(moduleDef * mod,optFlags * optflgs,const char * cname)10966 static const char *getPythonName(moduleDef *mod, optFlags *optflgs,
10967 const char *cname)
10968 {
10969 const char *pname;
10970 optFlag *of;
10971 autoPyNameDef *apnd;
10972
10973 /* Use the explicit name if given. */
10974 if ((of = getOptFlag(optflgs, "PyName", name_flag)) != NULL)
10975 return of->fvalue.sval;
10976
10977 /* Apply any automatic naming rules. */
10978 pname = cname;
10979
10980 for (apnd = mod->autopyname; apnd != NULL; apnd = apnd->next)
10981 {
10982 size_t len = strlen(apnd->remove_leading);
10983
10984 if (strncmp(pname, apnd->remove_leading, len) == 0)
10985 pname += len;
10986 }
10987
10988 return pname;
10989 }
10990
10991
10992 /*
10993 * Cache a name in a module. Entries in the cache are stored in order of
10994 * decreasing length.
10995 */
cacheName(sipSpec * pt,const char * name)10996 nameDef *cacheName(sipSpec *pt, const char *name)
10997 {
10998 nameDef *nd, **ndp;
10999 size_t len;
11000
11001 /* Allow callers to be lazy about checking if there is really a name. */
11002 if (name == NULL)
11003 return NULL;
11004
11005 /* Skip entries that are too large. */
11006 ndp = &pt->namecache;
11007 len = strlen(name);
11008
11009 while (*ndp != NULL && (*ndp)->len > len)
11010 ndp = &(*ndp)->next;
11011
11012 /* Check entries that are the right length. */
11013 for (nd = *ndp; nd != NULL && nd->len == len; nd = nd->next)
11014 if (memcmp(nd->text, name, len) == 0)
11015 return nd;
11016
11017 /* Create a new one. */
11018 nd = sipMalloc(sizeof (nameDef));
11019
11020 nd->nameflags = 0;
11021 nd->text = name;
11022 nd->len = len;
11023 nd->next = *ndp;
11024
11025 *ndp = nd;
11026
11027 return nd;
11028 }
11029
11030
11031 /*
11032 * Find (or create) an overloaded function name.
11033 */
findFunction(sipSpec * pt,moduleDef * mod,classDef * c_scope,ifaceFileDef * ns_scope,mappedTypeDef * mt_scope,const char * pname,int hwcode,int nrargs,int no_arg_parser)11034 static memberDef *findFunction(sipSpec *pt, moduleDef *mod, classDef *c_scope,
11035 ifaceFileDef *ns_scope, mappedTypeDef *mt_scope, const char *pname,
11036 int hwcode, int nrargs, int no_arg_parser)
11037 {
11038 static struct slot_map {
11039 const char *name; /* The slot name. */
11040 slotType type; /* The corresponding type. */
11041 int needs_hwcode; /* Set if handwritten code is required. */
11042 int nrargs; /* Nr. of arguments. */
11043 } slot_table[] = {
11044 {"__str__", str_slot, TRUE, 0},
11045 {"__int__", int_slot, FALSE, 0},
11046 {"__float__", float_slot, FALSE, 0},
11047 {"__len__", len_slot, TRUE, 0},
11048 {"__contains__", contains_slot, TRUE, 1},
11049 {"__add__", add_slot, FALSE, 1},
11050 {"__sub__", sub_slot, FALSE, 1},
11051 {"__mul__", mul_slot, FALSE, 1},
11052 {"__mod__", mod_slot, FALSE, 1},
11053 {"__floordiv__", floordiv_slot, TRUE, 1},
11054 {"__truediv__", truediv_slot, FALSE, 1},
11055 {"__and__", and_slot, FALSE, 1},
11056 {"__or__", or_slot, FALSE, 1},
11057 {"__xor__", xor_slot, FALSE, 1},
11058 {"__lshift__", lshift_slot, FALSE, 1},
11059 {"__rshift__", rshift_slot, FALSE, 1},
11060 {"__iadd__", iadd_slot, FALSE, 1},
11061 {"__isub__", isub_slot, FALSE, 1},
11062 {"__imul__", imul_slot, FALSE, 1},
11063 {"__imod__", imod_slot, FALSE, 1},
11064 {"__ifloordiv__", ifloordiv_slot, TRUE, 1},
11065 {"__itruediv__", itruediv_slot, FALSE, 1},
11066 {"__iand__", iand_slot, FALSE, 1},
11067 {"__ior__", ior_slot, FALSE, 1},
11068 {"__ixor__", ixor_slot, FALSE, 1},
11069 {"__ilshift__", ilshift_slot, FALSE, 1},
11070 {"__irshift__", irshift_slot, FALSE, 1},
11071 {"__invert__", invert_slot, FALSE, 0},
11072 {"__call__", call_slot, FALSE, -1},
11073 {"__getitem__", getitem_slot, FALSE, 1},
11074 {"__setitem__", setitem_slot, TRUE, 2},
11075 {"__delitem__", delitem_slot, TRUE, 1},
11076 {"__lt__", lt_slot, FALSE, 1},
11077 {"__le__", le_slot, FALSE, 1},
11078 {"__eq__", eq_slot, FALSE, 1},
11079 {"__ne__", ne_slot, FALSE, 1},
11080 {"__gt__", gt_slot, FALSE, 1},
11081 {"__ge__", ge_slot, FALSE, 1},
11082 {"__cmp__", cmp_slot, FALSE, 1},
11083 {"__bool__", bool_slot, TRUE, 0},
11084 {"__nonzero__", bool_slot, TRUE, 0},
11085 {"__neg__", neg_slot, FALSE, 0},
11086 {"__pos__", pos_slot, FALSE, 0},
11087 {"__abs__", abs_slot, TRUE, 0},
11088 {"__repr__", repr_slot, TRUE, 0},
11089 {"__hash__", hash_slot, TRUE, 0},
11090 {"__index__", index_slot, TRUE, 0},
11091 {"__iter__", iter_slot, TRUE, 0},
11092 {"__next__", next_slot, TRUE, 0},
11093 {"__setattr__", setattr_slot, TRUE, 2},
11094 {"__delattr__", delattr_slot, TRUE, 1},
11095 {"__matmul__", matmul_slot, FALSE, 1},
11096 {"__imatmul__", imatmul_slot, FALSE, 1},
11097 {"__await__", await_slot, TRUE, 0},
11098 {"__aiter__", aiter_slot, TRUE, 0},
11099 {"__anext__", anext_slot, TRUE, 0},
11100 {NULL, no_slot, FALSE, 0}
11101 };
11102
11103 memberDef *md, **flist;
11104 struct slot_map *sm;
11105 slotType st;
11106
11107 /* Get the slot type. */
11108 st = no_slot;
11109
11110 for (sm = slot_table; sm->name != NULL; ++sm)
11111 if (strcmp(sm->name, pname) == 0)
11112 {
11113 if (sm->needs_hwcode && !hwcode)
11114 yyerror("This Python slot requires %MethodCode");
11115
11116 if (sm->nrargs >= 0)
11117 {
11118 if (mt_scope == NULL && c_scope == NULL)
11119 {
11120 /* Global operators need one extra argument. */
11121 if (sm -> nrargs + 1 != nrargs)
11122 yyerror("Incorrect number of arguments to global operator");
11123 }
11124 else if (sm->nrargs != nrargs)
11125 yyerror("Incorrect number of arguments to Python slot");
11126 }
11127
11128 st = sm->type;
11129
11130 break;
11131 }
11132
11133 /* Check there is no name clash. */
11134 checkAttributes(pt, mod, c_scope, mt_scope, pname, TRUE);
11135
11136 /* See if it already exists. */
11137 if (mt_scope != NULL)
11138 flist = &mt_scope->members;
11139 else if (c_scope != NULL)
11140 flist = &c_scope->members;
11141 else
11142 flist = &mod->othfuncs;
11143
11144 /* __delattr__ is implemented as __setattr__. */
11145 if (st == delattr_slot)
11146 {
11147 if (inMainModule())
11148 setIsUsedName(cacheName(pt, pname));
11149
11150 st = setattr_slot;
11151 pname = "__setattr__";
11152 }
11153
11154 for (md = *flist; md != NULL; md = md->next)
11155 if (strcmp(md->pyname->text, pname) == 0 && md->module == mod)
11156 break;
11157
11158 if (md == NULL)
11159 {
11160 /* Create a new one. */
11161 md = sipMalloc(sizeof (memberDef));
11162
11163 md->pyname = cacheName(pt, pname);
11164 md->memberflags = 0;
11165 md->slot = st;
11166 md->module = mod;
11167 md->ns_scope = ns_scope;
11168 md->next = *flist;
11169
11170 *flist = md;
11171
11172 if (inMainModule())
11173 setIsUsedName(md->pyname);
11174
11175 if (no_arg_parser)
11176 setNoArgParser(md);
11177 }
11178 else if (noArgParser(md))
11179 yyerror("Another overload has already been defined that is annotated as /NoArgParser/");
11180
11181 /* Global operators are a subset. */
11182 if (mt_scope == NULL && c_scope == NULL && st != no_slot && st != neg_slot && st != pos_slot && !isNumberSlot(md) && !isInplaceNumberSlot(md) && !isRichCompareSlot(md))
11183 yyerror("Global operators must be either numeric or comparison operators");
11184
11185 return md;
11186 }
11187
11188
11189 /*
11190 * Search a set of flags for a particular one.
11191 */
findOptFlag(optFlags * flgs,const char * name)11192 static optFlag *findOptFlag(optFlags *flgs, const char *name)
11193 {
11194 int f;
11195
11196 for (f = 0; f < flgs->nrFlags; ++f)
11197 {
11198 optFlag *of = &flgs->flags[f];
11199
11200 if (strcmp(of->fname, name) == 0)
11201 return of;
11202 }
11203
11204 return NULL;
11205 }
11206
11207
11208 /*
11209 * Search a set of flags for a particular one and check its type.
11210 */
getOptFlag(optFlags * flgs,const char * name,flagType ft)11211 static optFlag *getOptFlag(optFlags *flgs, const char *name, flagType ft)
11212 {
11213 optFlag *of = findOptFlag(flgs, name);
11214
11215 if (of != NULL)
11216 {
11217 /* An optional name can look like a boolean or a name. */
11218 if (ft == opt_name_flag)
11219 {
11220 if (of->ftype == bool_flag)
11221 {
11222 of->ftype = opt_name_flag;
11223 of->fvalue.sval = NULL;
11224 }
11225 else if (of->ftype == name_flag)
11226 {
11227 of->ftype = opt_name_flag;
11228 }
11229 }
11230
11231 /* An optional integer can look like a boolean or an integer. */
11232 if (ft == opt_integer_flag)
11233 {
11234 if (of->ftype == bool_flag)
11235 {
11236 of->ftype = opt_integer_flag;
11237 of->fvalue.ival = -1;
11238 }
11239 else if (of->ftype == integer_flag)
11240 {
11241 of->ftype = opt_integer_flag;
11242 }
11243 }
11244
11245 /* A string list will look like a string. */
11246 if (ft == string_list_flag && of->ftype == string_flag)
11247 {
11248 char *s;
11249
11250 s = of->fvalue.sval;
11251 of->fvalue.slval = NULL;
11252
11253 while (*s != '\0')
11254 {
11255 char *start;
11256
11257 while (*s == ' ')
11258 ++s;
11259
11260 start = s;
11261
11262 if (*start != '\0')
11263 {
11264 char saved, *end;
11265
11266 for (end = start + 1; *end != ' ' && *end != '\0'; ++end)
11267 ;
11268
11269 saved = *end;
11270 *end = '\0';
11271
11272 appendString(&of->fvalue.slval, start);
11273
11274 *end = saved;
11275 s = end;
11276 }
11277 }
11278
11279 of->ftype = string_list_flag;
11280 }
11281
11282 if (ft != of->ftype)
11283 yyerror("Annotation has a value of the wrong type");
11284 }
11285
11286 return of;
11287 }
11288
11289
11290 /*
11291 * Append a string to a list of them.
11292 */
appendString(stringList ** headp,const char * s)11293 void appendString(stringList **headp, const char *s)
11294 {
11295 stringList *sl;
11296
11297 /* Create the new entry. */
11298
11299 sl = sipMalloc(sizeof (stringList));
11300
11301 sl -> s = s;
11302 sl -> next = NULL;
11303
11304 /* Append it to the list. */
11305
11306 while (*headp != NULL)
11307 headp = &(*headp) -> next;
11308
11309 *headp = sl;
11310 }
11311
11312
11313 /*
11314 * A name is going to be used as a Python attribute name within a Python scope
11315 * (ie. a Python dictionary), so check against what we already know is going in
11316 * the same scope in case there is a clash.
11317 */
checkAttributes(sipSpec * pt,moduleDef * mod,classDef * py_c_scope,mappedTypeDef * py_mt_scope,const char * attr,int isfunc)11318 static void checkAttributes(sipSpec *pt, moduleDef *mod, classDef *py_c_scope,
11319 mappedTypeDef *py_mt_scope, const char *attr, int isfunc)
11320 {
11321 enumDef *ed;
11322 varDef *vd;
11323 classDef *cd;
11324
11325 /* We don't do any check for a non-strict parse. */
11326 if (!strictParse)
11327 return;
11328
11329 /* Check the enums. */
11330 for (ed = pt->enums; ed != NULL; ed = ed->next)
11331 {
11332 if (ed->pyname == NULL)
11333 continue;
11334
11335 if (py_c_scope != NULL)
11336 {
11337 if (ed->ecd != py_c_scope)
11338 continue;
11339 }
11340 else if (py_mt_scope != NULL)
11341 {
11342 if (ed->emtd != py_mt_scope)
11343 continue;
11344 }
11345 else if (ed->ecd != NULL || ed->emtd != NULL)
11346 {
11347 continue;
11348 }
11349
11350 if (strcmp(ed->pyname->text, attr) == 0)
11351 yyerror("There is already an enum in scope with the same Python name");
11352
11353 if (!isScopedEnum(ed))
11354 {
11355 enumMemberDef *emd;
11356
11357 for (emd = ed->members; emd != NULL; emd = emd->next)
11358 if (strcmp(emd->pyname->text, attr) == 0)
11359 yyerror("There is already an enum member in scope with the same Python name");
11360 }
11361 }
11362
11363 /*
11364 * Only check the members if this attribute isn't a member because we can
11365 * handle members with the same name in the same scope.
11366 */
11367 if (!isfunc)
11368 {
11369 memberDef *md, *membs;
11370 overDef *overs;
11371
11372 if (py_mt_scope != NULL)
11373 {
11374 membs = py_mt_scope->members;
11375 overs = py_mt_scope->overs;
11376 }
11377 else if (py_c_scope != NULL)
11378 {
11379 membs = py_c_scope->members;
11380 overs = py_c_scope->overs;
11381 }
11382 else
11383 {
11384 membs = mod->othfuncs;
11385 overs = mod->overs;
11386 }
11387
11388 for (md = membs; md != NULL; md = md->next)
11389 {
11390 overDef *od;
11391
11392 if (strcmp(md->pyname->text, attr) != 0)
11393 continue;
11394
11395 /* Check for a conflict with all overloads. */
11396 for (od = overs; od != NULL; od = od->next)
11397 {
11398 if (od->common != md)
11399 continue;
11400
11401 yyerror("There is already a function in scope with the same Python name");
11402 }
11403 }
11404 }
11405
11406 /* If the scope was a mapped type then that's all we have to check. */
11407 if (py_mt_scope != NULL)
11408 return;
11409
11410 /* Check the variables. */
11411 for (vd = pt->vars; vd != NULL; vd = vd->next)
11412 {
11413 if (vd->ecd != py_c_scope)
11414 continue;
11415
11416 if (strcmp(vd->pyname->text,attr) == 0)
11417 yyerror("There is already a variable in scope with the same Python name");
11418 }
11419
11420 /* Check the classes. */
11421 for (cd = pt->classes; cd != NULL; cd = cd->next)
11422 {
11423 if (cd->ecd != py_c_scope || cd->pyname == NULL)
11424 continue;
11425
11426 if (strcmp(cd->pyname->text, attr) == 0 && !isExternal(cd))
11427 yyerror("There is already a class or namespace in scope with the same Python name");
11428 }
11429
11430 /* Check the exceptions. */
11431 if (py_c_scope == NULL)
11432 {
11433 exceptionDef *xd;
11434
11435 for (xd = pt->exceptions; xd != NULL; xd = xd->next)
11436 if (xd->pyname != NULL && strcmp(xd->pyname, attr) == 0)
11437 yyerror("There is already an exception with the same Python name");
11438 }
11439
11440 /* Check the properties. */
11441 if (py_c_scope != NULL)
11442 {
11443 propertyDef *pd;
11444
11445 for (pd = py_c_scope->properties; pd != NULL; pd = pd->next)
11446 if (strcmp(pd->name->text, attr) == 0)
11447 yyerror("There is already a property with the same name");
11448 }
11449 }
11450
11451
11452 /*
11453 * Append a code block to a list of them.
11454 */
appendCodeBlock(codeBlockList ** headp,codeBlock * cb)11455 static void appendCodeBlock(codeBlockList **headp, codeBlock *cb)
11456 {
11457 codeBlockList *cbl;
11458
11459 /* Handle the trivial case. */
11460 if (cb == NULL)
11461 return;
11462
11463 /* Find the end of the list. */
11464 while (*headp != NULL)
11465 {
11466 /* Ignore if the block is already in the list. */
11467 if ((*headp)->block == cb)
11468 return;
11469
11470 headp = &(*headp)->next;
11471 }
11472
11473 cbl = sipMalloc(sizeof (codeBlockList));
11474 cbl->block = cb;
11475
11476 *headp = cbl;
11477 }
11478
11479
11480 /*
11481 * Append a code block list to an existing list.
11482 */
appendCodeBlockList(codeBlockList ** headp,codeBlockList * cbl)11483 void appendCodeBlockList(codeBlockList **headp, codeBlockList *cbl)
11484 {
11485 while (cbl != NULL)
11486 {
11487 appendCodeBlock(headp, cbl->block);
11488 cbl = cbl->next;
11489 }
11490 }
11491
11492
11493 /*
11494 * Handle the end of a fully parsed a file.
11495 */
handleEOF()11496 static void handleEOF()
11497 {
11498 /*
11499 * Check that the number of nested if's is the same as when we started
11500 * the file.
11501 */
11502
11503 if (stackPtr > currentContext.ifdepth)
11504 fatal("Too many %%If statements in %s\n", previousFile);
11505
11506 if (stackPtr < currentContext.ifdepth)
11507 fatal("Too many %%End statements in %s\n", previousFile);
11508 }
11509
11510
11511 /*
11512 * Handle the end of a fully parsed a module.
11513 */
handleEOM()11514 static void handleEOM()
11515 {
11516 moduleDef *from;
11517
11518 /* Check it has been named. */
11519 if (currentModule->name == NULL)
11520 fatal("No %%Module has been specified for module defined in %s\n",
11521 previousFile);
11522
11523 from = currentContext.prevmod;
11524
11525 if (from != NULL)
11526 {
11527 if (from->encoding == no_type)
11528 from->encoding = currentModule->encoding;
11529
11530 if (isCallSuperInitUndefined(from))
11531 {
11532 if (isCallSuperInitYes(currentModule))
11533 setCallSuperInitYes(from);
11534 else
11535 setCallSuperInitNo(from);
11536 }
11537 }
11538
11539 /* The previous module is now current. */
11540 currentModule = from;
11541 }
11542
11543
11544 /*
11545 * Find an existing qualifier.
11546 */
findQualifier(const char * name)11547 static qualDef *findQualifier(const char *name)
11548 {
11549 moduleDef *mod;
11550
11551 for (mod = currentSpec->modules; mod != NULL; mod = mod->next)
11552 {
11553 qualDef *qd;
11554
11555 for (qd = mod->qualifiers; qd != NULL; qd = qd->next)
11556 if (strcmp(qd->name, name) == 0)
11557 return qd;
11558 }
11559
11560 /* Qualifiers corresponding to the SIP version are created on the fly. */
11561 if (name[0] == 'S' && name[1] == 'I' && name[2] == 'P' && name[3] == '_')
11562 {
11563 const char *cp = &name[3];
11564 int major, minor, patch;
11565
11566 cp = getInt(cp, &major);
11567 cp = getInt(cp, &minor);
11568 cp = getInt(cp, &patch);
11569
11570 if (*cp != '\0')
11571 yyerror("Unexpected character after SIP version number");
11572
11573 return allocQualifier(currentModule, -1,
11574 (major << 16) | (minor << 8) | patch, TRUE, name,
11575 time_qualifier);
11576 }
11577
11578 return NULL;
11579 }
11580
11581
11582 /*
11583 * Get an integer from string.
11584 */
getInt(const char * cp,int * ip)11585 static const char *getInt(const char *cp, int *ip)
11586 {
11587 /* Handle the default value. */
11588 *ip = 0;
11589
11590 if (*cp == '\0')
11591 return cp;
11592
11593 /* There must be a leading underscore. */
11594 if (*cp++ != '_')
11595 yyerror("An underscore must separate the parts of a SIP version number");
11596
11597 while (isdigit(*cp))
11598 {
11599 *ip *= 10;
11600 *ip += *cp - '0';
11601 ++cp;
11602 }
11603
11604 return cp;
11605 }
11606
11607
11608 /*
11609 * Find an existing API.
11610 */
findAPI(sipSpec * pt,const char * name)11611 apiVersionRangeDef *findAPI(sipSpec *pt, const char *name)
11612 {
11613 moduleDef *mod;
11614
11615 for (mod = pt->modules; mod != NULL; mod = mod->next)
11616 {
11617 apiVersionRangeDef *avd;
11618
11619 for (avd = mod->api_versions; avd != NULL; avd = avd->next)
11620 if (strcmp(avd->api_name->text, name) == 0)
11621 return avd;
11622 }
11623
11624 return NULL;
11625 }
11626
11627
11628 /*
11629 * Return a copy of a scoped name.
11630 */
copyScopedName(scopedNameDef * snd)11631 scopedNameDef *copyScopedName(scopedNameDef *snd)
11632 {
11633 scopedNameDef *head;
11634
11635 head = NULL;
11636
11637 while (snd != NULL)
11638 {
11639 appendScopedName(&head,text2scopePart(snd -> name));
11640 snd = snd -> next;
11641 }
11642
11643 return head;
11644 }
11645
11646
11647 /*
11648 * Append a name to a list of scopes.
11649 */
appendScopedName(scopedNameDef ** headp,scopedNameDef * newsnd)11650 void appendScopedName(scopedNameDef **headp,scopedNameDef *newsnd)
11651 {
11652 while (*headp != NULL)
11653 headp = &(*headp) -> next;
11654
11655 *headp = newsnd;
11656 }
11657
11658
11659 /*
11660 * Free a scoped name - but not the text itself.
11661 */
freeScopedName(scopedNameDef * snd)11662 void freeScopedName(scopedNameDef *snd)
11663 {
11664 while (snd != NULL)
11665 {
11666 scopedNameDef *next = snd -> next;
11667
11668 free(snd);
11669
11670 snd = next;
11671 }
11672 }
11673
11674
11675 /*
11676 * Convert a text string to a scope part structure.
11677 */
text2scopePart(char * text)11678 scopedNameDef *text2scopePart(char *text)
11679 {
11680 scopedNameDef *snd;
11681
11682 snd = sipMalloc(sizeof (scopedNameDef));
11683
11684 snd->name = text;
11685 snd->next = NULL;
11686
11687 return snd;
11688 }
11689
11690
11691 /*
11692 * Convert a text string to a fully scoped name.
11693 */
text2scopedName(ifaceFileDef * scope,char * text)11694 static scopedNameDef *text2scopedName(ifaceFileDef *scope, char *text)
11695 {
11696 return scopeScopedName(scope, text2scopePart(text));
11697 }
11698
11699
11700 /*
11701 * Prepend any current scope to a scoped name.
11702 */
scopeScopedName(ifaceFileDef * scope,scopedNameDef * name)11703 static scopedNameDef *scopeScopedName(ifaceFileDef *scope, scopedNameDef *name)
11704 {
11705 scopedNameDef *snd;
11706
11707 snd = (scope != NULL ? copyScopedName(scope->fqcname) : text2scopePart(""));
11708
11709 appendScopedName(&snd, name);
11710
11711 return snd;
11712 }
11713
11714
11715 /*
11716 * Return a pointer to the tail part of a scoped name.
11717 */
scopedNameTail(scopedNameDef * snd)11718 char *scopedNameTail(scopedNameDef *snd)
11719 {
11720 if (snd == NULL)
11721 return NULL;
11722
11723 while (snd->next != NULL)
11724 snd = snd->next;
11725
11726 return snd->name;
11727 }
11728
11729
11730 /*
11731 * Push the given scope onto the scope stack.
11732 */
pushScope(classDef * scope)11733 static void pushScope(classDef *scope)
11734 {
11735 if (currentScopeIdx >= MAX_NESTED_SCOPE)
11736 fatal("Internal error: increase the value of MAX_NESTED_SCOPE\n");
11737
11738 scopeStack[currentScopeIdx] = scope;
11739 sectFlagsStack[currentScopeIdx] = sectionFlags;
11740
11741 ++currentScopeIdx;
11742 }
11743
11744
11745 /*
11746 * Pop the scope stack.
11747 */
popScope(void)11748 static void popScope(void)
11749 {
11750 if (currentScopeIdx > 0)
11751 sectionFlags = sectFlagsStack[--currentScopeIdx];
11752 }
11753
11754
11755 /*
11756 * Return non-zero if the current input should be parsed rather than be
11757 * skipped.
11758 */
notSkipping()11759 static int notSkipping()
11760 {
11761 return (stackPtr == 0 ? TRUE : skipStack[stackPtr - 1]);
11762 }
11763
11764
11765 /*
11766 * Return the value of an expression involving a time period.
11767 */
timePeriod(const char * lname,const char * uname)11768 static int timePeriod(const char *lname, const char *uname)
11769 {
11770 int line;
11771 qualDef *qd, *lower, *upper;
11772 moduleDef *mod;
11773
11774 if (lname == NULL)
11775 lower = NULL;
11776 else if ((lower = findQualifier(lname)) == NULL || lower->qtype != time_qualifier)
11777 yyerror("Lower bound is not a time version");
11778
11779 if (uname == NULL)
11780 upper = NULL;
11781 else if ((upper = findQualifier(uname)) == NULL || upper->qtype != time_qualifier)
11782 yyerror("Upper bound is not a time version");
11783
11784 /* Sanity checks on the bounds. */
11785 if (lower == NULL && upper == NULL)
11786 yyerror("Lower and upper bounds cannot both be omitted");
11787
11788 if (lower != NULL && upper != NULL)
11789 {
11790 if (lower->module != upper->module || lower->line != upper->line)
11791 yyerror("Lower and upper bounds are from different timelines");
11792
11793 if (lower == upper)
11794 yyerror("Lower and upper bounds must be different");
11795
11796 if (lower->order > upper->order)
11797 yyerror("Later version specified as lower bound");
11798 }
11799
11800 /* Go through each slot in the relevant timeline. */
11801 if (lower != NULL)
11802 {
11803 mod = lower->module;
11804 line = lower->line;
11805 }
11806 else
11807 {
11808 mod = upper->module;
11809 line = upper->line;
11810 }
11811
11812 /* Handle the SIP version number pseudo-timeline. */
11813 if (line < 0)
11814 {
11815 if (lower != NULL && sipVersion < lower->order)
11816 return FALSE;
11817
11818 if (upper != NULL && sipVersion >= upper->order)
11819 return FALSE;
11820
11821 return TRUE;
11822 }
11823
11824 for (qd = mod->qualifiers; qd != NULL; qd = qd->next)
11825 {
11826 if (qd->qtype != time_qualifier || qd->line != line)
11827 continue;
11828
11829 if (selectedQualifier(neededQualifiers, qd))
11830 {
11831 if (lower != NULL && qd->order < lower->order)
11832 return FALSE;
11833
11834 if (upper != NULL && qd->order >= upper->order)
11835 return FALSE;
11836
11837 return TRUE;
11838 }
11839 }
11840
11841 /*
11842 * If there is no upper bound then assume the expression is true unless
11843 * the lower bound is a backstop.
11844 */
11845 if (upper == NULL)
11846 return !isBackstop(lower);
11847
11848 /*
11849 * If the upper limit corresponds to a backstop then assume the expression
11850 * is true.
11851 */
11852 return isBackstop(upper);
11853 }
11854
11855
11856 /*
11857 * See if a qualifier is a backstop.
11858 */
isBackstop(qualDef * qd)11859 static int isBackstop(qualDef *qd)
11860 {
11861 stringList *sl;
11862
11863 for (sl = backstops; sl != NULL; sl = sl->next)
11864 if (strcmp(qd->name, sl->s) == 0)
11865 return TRUE;
11866
11867 return FALSE;
11868 }
11869
11870
11871 /*
11872 * Return the value of an expression involving a single platform or feature.
11873 */
platOrFeature(char * name,int optnot)11874 static int platOrFeature(char *name, int optnot)
11875 {
11876 int this;
11877 qualDef *qd;
11878
11879 if ((qd = findQualifier(name)) == NULL || qd->qtype == time_qualifier)
11880 yyerror("No such platform or feature");
11881
11882 /* Assume this sub-expression is false. */
11883
11884 this = FALSE;
11885
11886 if (qd->qtype == feature_qualifier)
11887 {
11888 if (!excludedFeature(excludedQualifiers, qd))
11889 this = TRUE;
11890 }
11891 else
11892 {
11893 if (!strictParse)
11894 {
11895 if (optnot)
11896 {
11897 moduleDef *mod;
11898
11899 /* Add every platform except the one we have. */
11900 for (mod = currentSpec->modules; mod != NULL; mod = mod->next)
11901 {
11902 qualDef *not_qd;
11903
11904 for (not_qd = mod->qualifiers; not_qd != NULL; not_qd = not_qd->next)
11905 if (not_qd->qtype == platform_qualifier && strcmp(not_qd->name, qd->name) != 0)
11906 addPlatform(not_qd);
11907 }
11908 }
11909 else
11910 {
11911 addPlatform(qd);
11912 }
11913
11914 /*
11915 * If it is a non-strict parse then this is always TRUE, ie. we
11916 * never skip because of the platform.
11917 */
11918 return TRUE;
11919 }
11920
11921 if (selectedQualifier(neededQualifiers, qd))
11922 this = TRUE;
11923 }
11924
11925 if (optnot)
11926 this = !this;
11927
11928 return this;
11929 }
11930
11931
11932 /*
11933 * Add a platform to the current list of platforms if it is not already there.
11934 */
addPlatform(qualDef * qd)11935 static void addPlatform(qualDef *qd)
11936 {
11937 platformDef *pd;
11938
11939 for (pd = currentPlatforms; pd != NULL; pd = pd->next)
11940 if (pd->qualifier == qd)
11941 return;
11942
11943 pd = sipMalloc(sizeof (platformDef));
11944 pd->qualifier = qd;
11945 pd->next = currentPlatforms;
11946 currentPlatforms = pd;
11947 }
11948
11949
11950 /*
11951 * Return TRUE if the given qualifier is excluded.
11952 */
excludedFeature(stringList * xsl,qualDef * qd)11953 int excludedFeature(stringList *xsl, qualDef *qd)
11954 {
11955 while (xsl != NULL)
11956 {
11957 if (strcmp(qd->name, xsl->s) == 0)
11958 return TRUE;
11959
11960 xsl = xsl->next;
11961 }
11962
11963 return !qd->default_enabled;
11964 }
11965
11966
11967 /*
11968 * Return TRUE if the given qualifier is needed.
11969 */
selectedQualifier(stringList * needed_qualifiers,qualDef * qd)11970 int selectedQualifier(stringList *needed_qualifiers, qualDef *qd)
11971 {
11972 stringList *sl;
11973
11974 for (sl = needed_qualifiers; sl != NULL; sl = sl->next)
11975 if (strcmp(qd->name, sl->s) == 0)
11976 return qd->default_enabled;
11977
11978 return FALSE;
11979 }
11980
11981
11982 /*
11983 * Return the current scope. currentScope() is only valid if notSkipping()
11984 * returns non-zero.
11985 */
currentScope(void)11986 static classDef *currentScope(void)
11987 {
11988 return (currentScopeIdx > 0 ? scopeStack[currentScopeIdx - 1] : NULL);
11989 }
11990
11991
11992 /*
11993 * Create a new qualifier.
11994 */
newQualifier(moduleDef * mod,int line,unsigned order,int default_enabled,const char * name,qualType qt)11995 static void newQualifier(moduleDef *mod, int line, unsigned order,
11996 int default_enabled, const char *name, qualType qt)
11997 {
11998 qualDef *qd;
11999
12000 /* See if it already exists. */
12001 if ((qd = findQualifier(name)) != NULL)
12002 {
12003 /*
12004 * We allow versions to be defined more than once so long as they are
12005 * in different timelines. It is sometimes necessary to define the
12006 * same timeline in multiple modules if a module that others depend on
12007 * is added during the timeline (eg. QtWebEngineCore).
12008 */
12009 if (qd->qtype != time_qualifier || qt != time_qualifier || (qd->module == mod && qd->line == line))
12010 yyerror("Version is already defined");
12011 }
12012
12013 allocQualifier(mod, line, order, default_enabled, name, qt);
12014 }
12015
12016
12017 /*
12018 * Allocate a new qualifier.
12019 */
allocQualifier(moduleDef * mod,int line,unsigned order,int default_enabled,const char * name,qualType qt)12020 static qualDef *allocQualifier(moduleDef *mod, int line, unsigned order,
12021 int default_enabled, const char *name, qualType qt)
12022 {
12023 qualDef *qd;
12024
12025 qd = sipMalloc(sizeof (qualDef));
12026
12027 qd->name = name;
12028 qd->qtype = qt;
12029 qd->module = mod;
12030 qd->line = line;
12031 qd->order = order;
12032 qd->default_enabled = default_enabled;
12033 qd->next = mod->qualifiers;
12034
12035 mod->qualifiers = qd;
12036
12037 return qd;
12038 }
12039
12040
12041 /*
12042 * Create a new imported module.
12043 */
newImport(const char * filename)12044 static void newImport(const char *filename)
12045 {
12046 moduleDef *from, *mod;
12047 moduleListDef *mld;
12048
12049 /* Create a new module if it has not already been defined. */
12050 for (mod = currentSpec->modules; mod != NULL; mod = mod->next)
12051 if (strcmp(mod->file, filename) == 0)
12052 break;
12053
12054 from = currentModule;
12055
12056 if (mod == NULL)
12057 {
12058 /* Read any configuration .toml file. */
12059 get_bindings_configuration(filename, &neededQualifiers,
12060 &excludedQualifiers);
12061
12062 newModule(NULL, filename);
12063 mod = currentModule;
12064 }
12065 else if (from->encoding == no_type)
12066 {
12067 /* Import any defaults from the already parsed module. */
12068 from->encoding = mod->encoding;
12069 }
12070
12071 /* Add the new import unless it has already been imported. */
12072 for (mld = from->imports; mld != NULL; mld = mld->next)
12073 if (mld->module == mod)
12074 return;
12075
12076 mld = sipMalloc(sizeof (moduleListDef));
12077 mld->module = mod;
12078 mld->next = from->imports;
12079
12080 from->imports = mld;
12081 }
12082
12083
12084 /*
12085 * Set up pointers to hook names.
12086 */
getHooks(optFlags * optflgs,char ** pre,char ** post)12087 static void getHooks(optFlags *optflgs,char **pre,char **post)
12088 {
12089 optFlag *of;
12090
12091 if ((of = getOptFlag(optflgs,"PreHook",name_flag)) != NULL)
12092 *pre = of -> fvalue.sval;
12093 else
12094 *pre = NULL;
12095
12096 if ((of = getOptFlag(optflgs,"PostHook",name_flag)) != NULL)
12097 *post = of -> fvalue.sval;
12098 else
12099 *post = NULL;
12100 }
12101
12102
12103 /*
12104 * Get the /Transfer/ option flag.
12105 */
getTransfer(optFlags * optflgs)12106 static int getTransfer(optFlags *optflgs)
12107 {
12108 return (getOptFlag(optflgs, "Transfer", bool_flag) != NULL);
12109 }
12110
12111
12112 /*
12113 * Get the /ReleaseGIL/ option flag.
12114 */
getReleaseGIL(optFlags * optflgs)12115 static int getReleaseGIL(optFlags *optflgs)
12116 {
12117 return (getOptFlag(optflgs, "ReleaseGIL", bool_flag) != NULL);
12118 }
12119
12120
12121 /*
12122 * Get the /HoldGIL/ option flag.
12123 */
getHoldGIL(optFlags * optflgs)12124 static int getHoldGIL(optFlags *optflgs)
12125 {
12126 return (getOptFlag(optflgs, "HoldGIL", bool_flag) != NULL);
12127 }
12128
12129
12130 /*
12131 * Get the /Deprecated/ option flag.
12132 */
getDeprecated(optFlags * optflgs)12133 static int getDeprecated(optFlags *optflgs)
12134 {
12135 return (getOptFlag(optflgs, "Deprecated", bool_flag) != NULL);
12136 }
12137
12138
12139 /*
12140 * Get the /AllowNone/ option flag.
12141 */
getAllowNone(optFlags * optflgs)12142 static int getAllowNone(optFlags *optflgs)
12143 {
12144 return (getOptFlag(optflgs, "AllowNone", bool_flag) != NULL);
12145 }
12146
12147
12148 /*
12149 * Get the /DisallowNone/ option flag.
12150 */
getDisallowNone(optFlags * optflgs)12151 static int getDisallowNone(optFlags *optflgs)
12152 {
12153 return (getOptFlag(optflgs, "DisallowNone", bool_flag) != NULL);
12154 }
12155
12156
12157 /*
12158 * Get the /VirtualErrorHandler/ option flag.
12159 */
getVirtErrorHandler(optFlags * optflgs)12160 static const char *getVirtErrorHandler(optFlags *optflgs)
12161 {
12162 optFlag *of = getOptFlag(optflgs, "VirtualErrorHandler", name_flag);
12163
12164 if (of == NULL)
12165 return NULL;
12166
12167 return of->fvalue.sval;
12168 }
12169
12170
12171 /*
12172 * Get the /TypeHintValue/ option flag.
12173 */
getTypeHintValue(optFlags * optflgs)12174 static const char *getTypeHintValue(optFlags *optflgs)
12175 {
12176 optFlag *of = getOptFlag(optflgs, "TypeHintValue", string_flag);
12177
12178 if (of == NULL)
12179 return NULL;
12180
12181 return of->fvalue.sval;
12182 }
12183
12184
12185 /*
12186 * Get the /TypeHint/, /TypeHintIn/ and /TypeHintOut/ option flags.
12187 */
getTypeHints(optFlags * optflgs,typeHintDef ** in,typeHintDef ** out)12188 static void getTypeHints(optFlags *optflgs, typeHintDef **in,
12189 typeHintDef **out)
12190 {
12191 optFlag *of;
12192 typeHintDef *thd;
12193
12194 if ((of = getOptFlag(optflgs, "TypeHint", string_flag)) != NULL)
12195 thd = newTypeHint(of->fvalue.sval);
12196 else
12197 thd = NULL;
12198
12199 if ((of = getOptFlag(optflgs, "TypeHintIn", string_flag)) != NULL)
12200 {
12201 if (thd != NULL)
12202 yywarning("/TypeHintIn/ overrides /TypeHint/");
12203
12204 *in = newTypeHint(of->fvalue.sval);
12205 }
12206 else
12207 {
12208 *in = thd;
12209 }
12210
12211 if ((of = getOptFlag(optflgs, "TypeHintOut", string_flag)) != NULL)
12212 {
12213 if (thd != NULL)
12214 yywarning("/TypeHintOut/ overrides /TypeHint/");
12215
12216 *out = newTypeHint(of->fvalue.sval);
12217 }
12218 else
12219 {
12220 *out = thd;
12221 }
12222 }
12223
12224
12225 /*
12226 * Get the /NoTypeHint/ option flag.
12227 */
getNoTypeHint(optFlags * optflgs)12228 static int getNoTypeHint(optFlags *optflgs)
12229 {
12230 return (getOptFlag(optflgs, "NoTypeHint", bool_flag) != NULL);
12231 }
12232
12233
12234 /*
12235 * Return TRUE if the PyQt5 plugin was specified.
12236 */
pluginPyQt5(sipSpec * pt)12237 int pluginPyQt5(sipSpec *pt)
12238 {
12239 return stringFind(pt->plugins, "PyQt5");
12240 }
12241
12242
12243 /*
12244 * Return TRUE if a list of strings contains a given entry.
12245 */
stringFind(stringList * sl,const char * s)12246 static int stringFind(stringList *sl, const char *s)
12247 {
12248 while (sl != NULL)
12249 {
12250 if (strcmp(sl->s, s) == 0)
12251 return TRUE;
12252
12253 sl = sl->next;
12254 }
12255
12256 return FALSE;
12257 }
12258
12259
12260 /*
12261 * Set the name of a module.
12262 */
setModuleName(sipSpec * pt,moduleDef * mod,const char * fullname)12263 static void setModuleName(sipSpec *pt, moduleDef *mod, const char *fullname)
12264 {
12265 mod->fullname = cacheName(pt, fullname);
12266
12267 if (inMainModule())
12268 setIsUsedName(mod->fullname);
12269
12270 if ((mod->name = strrchr(fullname, '.')) != NULL)
12271 mod->name++;
12272 else
12273 mod->name = fullname;
12274 }
12275
12276
12277 /*
12278 * Define a new class and set its name.
12279 */
defineClass(scopedNameDef * snd,classList * supers,optFlags * of)12280 static void defineClass(scopedNameDef *snd, classList *supers, optFlags *of)
12281 {
12282 classDef *cd;
12283 typeHintDef *in, *out;
12284
12285 getTypeHints(of, &in, &out);
12286
12287 cd = newClass(currentSpec, class_iface, getAPIRange(of),
12288 fullyQualifiedName(snd), getVirtErrorHandler(of), in, out,
12289 getTypeHintValue(of));
12290 cd->supers = supers;
12291
12292 pushScope(cd);
12293 }
12294
12295
12296 /*
12297 * Return a fully qualified scoped name.
12298 */
fullyQualifiedName(scopedNameDef * snd)12299 static scopedNameDef *fullyQualifiedName(scopedNameDef *snd)
12300 {
12301 classDef *scope = currentScope();
12302
12303 return scopeScopedName((scope != NULL ? scope->iff : NULL), snd);
12304 }
12305
12306
12307 /*
12308 * Complete the definition of a class.
12309 */
completeClass(scopedNameDef * snd,optFlags * of,int has_def)12310 static classDef *completeClass(scopedNameDef *snd, optFlags *of, int has_def)
12311 {
12312 classDef *cd = currentScope();
12313
12314 /* See if the class was defined or just declared. */
12315 if (has_def)
12316 {
12317 if (snd->next != NULL)
12318 yyerror("A scoped name cannot be given in a class/struct definition");
12319
12320 }
12321 else if (cd->supers != NULL)
12322 yyerror("Class/struct has super-classes but no definition");
12323 else
12324 setIsOpaque(cd);
12325
12326 finishClass(currentSpec, currentModule, cd, of);
12327 popScope();
12328
12329 /*
12330 * Check that external classes have only been declared at the global scope.
12331 */
12332 if (isExternal(cd) && currentScope() != NULL)
12333 yyerror("External classes/structs can only be declared in the global scope");
12334
12335 return cd;
12336 }
12337
12338
12339 /*
12340 * Add a variable to the list so that the list remains sorted.
12341 */
addVariable(sipSpec * pt,varDef * vd)12342 static void addVariable(sipSpec *pt, varDef *vd)
12343 {
12344 varDef **at = &pt->vars;
12345
12346 while (*at != NULL)
12347 {
12348 if (strcmp(vd->pyname->text, (*at)->pyname->text) < 0)
12349 break;
12350
12351 at = &(*at)->next;
12352 }
12353
12354 vd->next = *at;
12355 *at = vd;
12356 }
12357
12358
12359 /*
12360 * Update a type according to optional flags.
12361 */
applyTypeFlags(moduleDef * mod,argDef * ad,optFlags * flags)12362 static void applyTypeFlags(moduleDef *mod, argDef *ad, optFlags *flags)
12363 {
12364 getTypeHints(flags, &ad->typehint_in, &ad->typehint_out);
12365
12366 if (getOptFlag(flags, "PyInt", bool_flag) != NULL)
12367 {
12368 if (ad->atype == string_type)
12369 ad->atype = byte_type;
12370 else if (ad->atype == sstring_type)
12371 ad->atype = sbyte_type;
12372 else if (ad->atype == ustring_type)
12373 ad->atype = ubyte_type;
12374 }
12375
12376 if (ad->atype == string_type && !isArray(ad) && !isReference(ad))
12377 {
12378 optFlag *of;
12379
12380 if ((of = getOptFlag(flags, "Encoding", string_flag)) == NULL)
12381 {
12382 if (mod->encoding != no_type)
12383 ad->atype = mod->encoding;
12384 else
12385 ad->atype = string_type;
12386 }
12387 else if ((ad->atype = convertEncoding(of->fvalue.sval)) == no_type)
12388 yyerror("The value of the /Encoding/ annotation must be one of \"ASCII\", \"Latin-1\", \"UTF-8\" or \"None\"");
12389 }
12390 }
12391
12392
12393 /*
12394 * Return the keyword argument support converted from a string.
12395 */
convertKwArgs(const char * kwargs)12396 static KwArgs convertKwArgs(const char *kwargs)
12397 {
12398 if (strcmp(kwargs, "None") == 0)
12399 return NoKwArgs;
12400
12401 if (strcmp(kwargs, "All") == 0)
12402 return AllKwArgs;
12403
12404 if (strcmp(kwargs, "Optional") == 0)
12405 return OptionalKwArgs;
12406
12407 yyerror("The style of keyword argument support must be one of \"All\", \"Optional\" or \"None\"");
12408 }
12409
12410
12411 /*
12412 * Return the Format for a string.
12413 */
convertFormat(const char * format)12414 static Format convertFormat(const char *format)
12415 {
12416 if (strcmp(format, "raw") == 0)
12417 return raw;
12418
12419 if (strcmp(format, "deindented") == 0)
12420 return deindented;
12421
12422 yyerror("The docstring format must be either \"raw\" or \"deindented\"");
12423 }
12424
12425
12426 /*
12427 * Return the Signature for a string.
12428 */
convertSignature(const char * signature)12429 static Signature convertSignature(const char *signature)
12430 {
12431 if (strcmp(signature, "discarded") == 0)
12432 return discarded;
12433
12434 if (strcmp(signature, "prepended") == 0)
12435 return prepended;
12436
12437 if (strcmp(signature, "appended") == 0)
12438 return appended;
12439
12440 yyerror("The docstring signature must be either \"discarded\", \"prepended\" or \"appended\"");
12441 }
12442
12443
12444 /*
12445 * Return the argument type for a string with the given encoding or no_type if
12446 * the encoding was invalid.
12447 */
convertEncoding(const char * encoding)12448 static argType convertEncoding(const char *encoding)
12449 {
12450 if (strcmp(encoding, "ASCII") == 0)
12451 return ascii_string_type;
12452
12453 if (strcmp(encoding, "Latin-1") == 0)
12454 return latin1_string_type;
12455
12456 if (strcmp(encoding, "UTF-8") == 0)
12457 return utf8_string_type;
12458
12459 if (strcmp(encoding, "None") == 0)
12460 return string_type;
12461
12462 return no_type;
12463 }
12464
12465
12466 /*
12467 * Get the /API/ option flag.
12468 */
getAPIRange(optFlags * optflgs)12469 static apiVersionRangeDef *getAPIRange(optFlags *optflgs)
12470 {
12471 optFlag *of;
12472
12473 if ((of = getOptFlag(optflgs, "API", api_range_flag)) == NULL)
12474 return NULL;
12475
12476 deprecated("The /API/ annotation is deprecated and will be removed in v6");
12477
12478 return of->fvalue.aval;
12479 }
12480
12481
12482 /*
12483 * Return the API range structure and version number corresponding to the
12484 * given API range.
12485 */
convertAPIRange(moduleDef * mod,nameDef * name,int from,int to)12486 static apiVersionRangeDef *convertAPIRange(moduleDef *mod, nameDef *name,
12487 int from, int to)
12488 {
12489 int index;
12490 apiVersionRangeDef *avd, **avdp;
12491
12492 /* Handle the trivial case. */
12493 if (from == 0 && to == 0)
12494 return NULL;
12495
12496 for (index = 0, avdp = &mod->api_ranges; (*avdp) != NULL; avdp = &(*avdp)->next, ++index)
12497 {
12498 avd = *avdp;
12499
12500 if (avd->api_name == name && avd->from == from && avd->to == to)
12501 return avd;
12502 }
12503
12504 /* The new one must be appended so that version numbers remain valid. */
12505 avd = sipMalloc(sizeof (apiVersionRangeDef));
12506
12507 avd->api_name = name;
12508 avd->from = from;
12509 avd->to = to;
12510 avd->index = index;
12511
12512 avd->next = NULL;
12513 *avdp = avd;
12514
12515 return avd;
12516 }
12517
12518
12519 /*
12520 * Return the style of keyword argument support for a signature.
12521 */
keywordArgs(moduleDef * mod,optFlags * optflgs,signatureDef * sd,int need_name)12522 static KwArgs keywordArgs(moduleDef *mod, optFlags *optflgs, signatureDef *sd,
12523 int need_name)
12524 {
12525 KwArgs kwargs;
12526 optFlag *ka_anno;
12527
12528 /* See if there was an explicit annotation. */
12529 ka_anno = getOptFlag(optflgs, "KeywordArgs", string_flag);
12530
12531 if (ka_anno != NULL)
12532 kwargs = convertKwArgs(ka_anno->fvalue.sval);
12533 else
12534 kwargs = mod->kwargs;
12535
12536 /* An ellipsis cannot be used with keyword arguments. */
12537 if (sd->nrArgs > 0 && sd->args[sd->nrArgs - 1].atype == ellipsis_type)
12538 kwargs = NoKwArgs;
12539
12540 if (kwargs != NoKwArgs)
12541 {
12542 int a, is_name = FALSE;
12543
12544 /*
12545 * Mark argument names as being used and check there is at least one.
12546 */
12547 for (a = 0; a < sd->nrArgs; ++a)
12548 {
12549 argDef *ad = &sd->args[a];
12550
12551 if (kwargs == OptionalKwArgs && ad->defval == NULL)
12552 continue;
12553
12554 if (ad->name != NULL)
12555 {
12556 if (need_name || inMainModule())
12557 setIsUsedName(ad->name);
12558
12559 is_name = TRUE;
12560 }
12561 }
12562
12563 if (!is_name)
12564 kwargs = NoKwArgs;
12565 }
12566
12567 return kwargs;
12568 }
12569
12570
12571 /*
12572 * Extract the version of a string value optionally associated with a
12573 * particular feature.
12574 */
convertFeaturedString(char * fs)12575 static char *convertFeaturedString(char *fs)
12576 {
12577 while (fs != NULL)
12578 {
12579 char *next, *value;
12580
12581 /* Individual values are ';' separated. */
12582 if ((next = strchr(fs, ';')) != NULL)
12583 *next++ = '\0';
12584
12585 /* Features and values are ':' separated. */
12586 if ((value = strchr(fs, ':')) == NULL)
12587 {
12588 /* This is an unconditional value so just return it. */
12589 return strip(fs);
12590 }
12591
12592 *value++ = '\0';
12593
12594 if (isEnabledFeature(strip(fs)))
12595 return strip(value);
12596
12597 fs = next;
12598 }
12599
12600 /* No value was enabled. */
12601 return NULL;
12602 }
12603
12604
12605 /*
12606 * Return the stripped version of a string.
12607 */
strip(char * s)12608 static char *strip(char *s)
12609 {
12610 while (*s == ' ')
12611 ++s;
12612
12613 if (*s != '\0')
12614 {
12615 char *cp = &s[strlen(s) - 1];
12616
12617 while (*cp == ' ')
12618 *cp-- = '\0';
12619 }
12620
12621 return s;
12622 }
12623
12624
12625 /*
12626 * Return TRUE if the given feature is enabled.
12627 */
isEnabledFeature(const char * name)12628 static int isEnabledFeature(const char *name)
12629 {
12630 qualDef *qd;
12631
12632 if ((qd = findQualifier(name)) == NULL || qd->qtype != feature_qualifier)
12633 yyerror("No such feature");
12634
12635 return !excludedFeature(excludedQualifiers, qd);
12636 }
12637
12638
12639 /*
12640 * Add a property definition to a class.
12641 */
addProperty(sipSpec * pt,moduleDef * mod,classDef * cd,const char * name,const char * get,const char * set,docstringDef * docstring)12642 static void addProperty(sipSpec *pt, moduleDef *mod, classDef *cd,
12643 const char *name, const char *get, const char *set,
12644 docstringDef *docstring)
12645 {
12646 propertyDef *pd;
12647
12648 checkAttributes(pt, mod, cd, NULL, name, FALSE);
12649
12650 pd = sipMalloc(sizeof (propertyDef));
12651
12652 pd->name = cacheName(pt, name);
12653 pd->get = get;
12654 pd->set = set;
12655 pd->docstring = docstring;
12656 pd->platforms = currentPlatforms;
12657 pd->next = cd->properties;
12658
12659 cd->properties = pd;
12660
12661 if (inMainModule())
12662 setIsUsedName(pd->name);
12663 }
12664
12665
12666 /*
12667 * Configure a module and return the (possibly new) current module.
12668 */
configureModule(sipSpec * pt,moduleDef * module,const char * filename,const char * name,int c_module,KwArgs kwargs,int use_arg_names,int use_limited_api,int call_super_init,int all_raise_py_exc,const char * def_error_handler,docstringDef * docstring)12669 static moduleDef *configureModule(sipSpec *pt, moduleDef *module,
12670 const char *filename, const char *name, int c_module, KwArgs kwargs,
12671 int use_arg_names, int use_limited_api, int call_super_init,
12672 int all_raise_py_exc, const char *def_error_handler,
12673 docstringDef *docstring)
12674 {
12675 moduleDef *mod;
12676
12677 /* Check the module hasn't already been defined. */
12678 for (mod = pt->modules; mod != NULL; mod = mod->next)
12679 if (mod->fullname != NULL && strcmp(mod->fullname->text, name) == 0)
12680 yyerror("Module is already defined");
12681
12682 /*
12683 * If we are in a container module then create a component module and make
12684 * it current.
12685 */
12686 if (isContainer(module) || module->container != NULL)
12687 {
12688 mod = allocModule();
12689
12690 mod->file = filename;
12691 mod->container = (isContainer(module) ? module : module->container);
12692
12693 module = mod;
12694 }
12695
12696 setModuleName(pt, module, name);
12697 module->kwargs = kwargs;
12698 module->virt_error_handler = def_error_handler;
12699 module->docstring = docstring;
12700
12701 if (all_raise_py_exc)
12702 setAllRaisePyException(module);
12703
12704 if (use_arg_names)
12705 setUseArgNames(module);
12706
12707 if (use_limited_api)
12708 setUseLimitedAPI(module);
12709
12710 if (call_super_init == 0)
12711 setCallSuperInitNo(module);
12712 else if (call_super_init > 0)
12713 setCallSuperInitYes(module);
12714
12715 if (pt->genc < 0)
12716 pt->genc = c_module;
12717 else if (pt->genc != c_module)
12718 yyerror("Cannot mix C and C++ modules");
12719
12720 return module;
12721 }
12722
12723
12724 /*
12725 * Add a Python naming rule to a module.
12726 */
addAutoPyName(moduleDef * mod,const char * remove_leading)12727 static void addAutoPyName(moduleDef *mod, const char *remove_leading)
12728 {
12729 autoPyNameDef *apnd, **apndp;
12730
12731 for (apndp = &mod->autopyname; *apndp != NULL; apndp = &(*apndp)->next)
12732 ;
12733
12734 apnd = sipMalloc(sizeof (autoPyNameDef));
12735 apnd->remove_leading = remove_leading;
12736 apnd->next = *apndp;
12737
12738 *apndp = apnd;
12739 }
12740
12741
12742 /*
12743 * Check that no invalid or unknown annotations are given.
12744 */
checkAnnos(optFlags * annos,const char * valid[])12745 static void checkAnnos(optFlags *annos, const char *valid[])
12746 {
12747 int i;
12748
12749 if (parsingCSignature && annos->nrFlags != 0)
12750 yyerror("Annotations must not be used in explicit C/C++ signatures");
12751
12752 for (i = 0; i < annos->nrFlags; i++)
12753 {
12754 const char **name;
12755
12756 for (name = valid; *name != NULL; ++name)
12757 if (strcmp(*name, annos->flags[i].fname) == 0)
12758 break;
12759
12760 if (*name == NULL)
12761 yyerror("Annotation is unknown");
12762 }
12763 }
12764
12765
12766 /*
12767 * Handle any /KeepReference/ annotation for a type.
12768 */
handleKeepReference(optFlags * optflgs,argDef * ad,moduleDef * mod)12769 static void handleKeepReference(optFlags *optflgs, argDef *ad, moduleDef *mod)
12770 {
12771 optFlag *of;
12772
12773 if ((of = getOptFlag(optflgs, "KeepReference", opt_integer_flag)) != NULL)
12774 {
12775 setKeepReference(ad);
12776
12777 if ((ad->key = of->fvalue.ival) < -1)
12778 yyerror("/KeepReference/ key cannot be negative");
12779
12780 /* If there was no explicit key then auto-allocate one. */
12781 if (ad->key == -1)
12782 ad->key = mod->next_key--;
12783 }
12784 }
12785
12786
12787 /*
12788 * Configure the mapped type annotations that are also valid with mapped type
12789 * templates.
12790 */
mappedTypeAnnos(mappedTypeDef * mtd,optFlags * optflgs)12791 static void mappedTypeAnnos(mappedTypeDef *mtd, optFlags *optflgs)
12792 {
12793 if (getOptFlag(optflgs, "NoRelease", bool_flag) != NULL)
12794 setNoRelease(mtd);
12795
12796 if (getAllowNone(optflgs))
12797 setHandlesNone(mtd);
12798
12799 getTypeHints(optflgs, &mtd->typehint_in, &mtd->typehint_out);
12800 mtd->typehint_value = getTypeHintValue(optflgs);
12801 }
12802
12803
12804 /*
12805 * Initialise an argument with the derefences of another, plus a new one.
12806 */
add_new_deref(argDef * new,argDef * orig,int isconst)12807 static void add_new_deref(argDef *new, argDef *orig, int isconst)
12808 {
12809 if ((new->nrderefs = orig->nrderefs + 1) >= MAX_NR_DEREFS)
12810 yyerror("Internal error - increase the value of MAX_NR_DEREFS");
12811
12812 memcpy(&new->derefs[0], &orig->derefs[0], sizeof (new->derefs));
12813 new->derefs[orig->nrderefs] = isconst;
12814 }
12815
12816
12817 /*
12818 * Add the dereferences from one type to another.
12819 */
add_derefs(argDef * dst,argDef * src)12820 static void add_derefs(argDef *dst, argDef *src)
12821 {
12822 int i;
12823
12824 for (i = 0; i < src->nrderefs; ++i)
12825 {
12826 if (dst->nrderefs >= MAX_NR_DEREFS - 1)
12827 fatal("Internal error - increase the value of MAX_NR_DEREFS\n");
12828
12829 dst->derefs[dst->nrderefs++] = src->derefs[i];
12830 }
12831 }
12832
12833
12834 /*
12835 * Check if a word is a Python keyword (or has been at any time).
12836 */
isPyKeyword(const char * word)12837 int isPyKeyword(const char *word)
12838 {
12839 static const char *kwds[] = {
12840 "False", "None", "True", "and", "as", "assert", "break", "class",
12841 "continue", "def", "del", "elif", "else", "except", "finally", "for",
12842 "from", "global", "if", "import", "in", "is", "lambda", "nonlocal",
12843 "not", "or", "pass", "raise", "return", "try", "while", "with'"
12844 "yield",
12845 /* Historical keywords. */
12846 "exec", "print",
12847 NULL
12848 };
12849
12850 const char **kwd;
12851
12852 for (kwd = kwds; *kwd != NULL; ++kwd)
12853 if (strcmp(*kwd, word) == 0)
12854 return TRUE;
12855
12856 return FALSE;
12857 }
12858
12859
12860 /*
12861 * Check there is nothing after an ellipsis.
12862 */
checkEllipsis(signatureDef * sd)12863 static void checkEllipsis(signatureDef *sd)
12864 {
12865 int a;
12866
12867 for (a = 0; a < sd->nrArgs; ++a)
12868 if (sd->args[a].atype == ellipsis_type && a < sd->nrArgs - 1)
12869 yyerror("An ellipsis must be at the end of the argument list if /NoArgParser/ is not specified");
12870 }
12871
12872