File: sip.h

package info (click to toggle)
sip 2.5-2.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,340 kB
  • ctags: 1,472
  • sloc: ansic: 11,902; sh: 6,482; yacc: 1,987; cpp: 540; lex: 423; makefile: 104
file content (786 lines) | stat: -rw-r--r-- 25,030 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
/*
 * Copyright (c) 1998 - 2001 Phil Thompson <phil@river-bank.demon.co.uk>
 *
 * The main header file for SIP.
 */


#ifndef SIP_H
#define SIP_H

#include <stdio.h>
#include <sys/types.h>

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif


#ifdef TRUE
#undef TRUE
#endif

#ifdef FALSE
#undef FALSE
#endif

#define	TRUE	1
#define	FALSE	0


#define	MAX_NR_ARGS		20	/* Max. nr. args. to a function. */


/* For convenience. */

#define	classVersBaseName(cvd)	((cvd) -> common -> iff -> name -> text)
#define	classVersFQName(cvd)	((cvd) -> common -> iff -> fqname)
#define	versionIsSubset(v1,v2)	((v2) -> secondary == NULL || \
				 (v1) -> secondary == (v2) -> secondary)


/* Handle section flags. */

#define	SECT_IS_PUBLIC		0x0001	/* It is public. */
#define	SECT_IS_PROT		0x0002	/* It is protected. */
#define	SECT_IS_PRIVATE		0x0004	/* It is private. */
#define	SECT_IS_SLOT		0x0008	/* It is a slot. */
#define	SECT_IS_SIGNAL		0x0010	/* It is a signal. */
#define	SECT_IS_PYMETHOD	0x0020	/* It is a Python method. */
#define	SECT_IS_PYNUMMETHOD	0x0040	/* It is a Python number method. */
#define	SECT_IS_PYSEQMETHOD	0x0080	/* It is a Python sequence method. */
#define	SECT_IS_PYMAPMETHOD	0x0100	/* It is a Python mapping method. */
#define	SECT_IS_PYCMPMETHOD	0x0200	/* It is a Python compare method. */


/* Handle class version flags. */

#define	CLASSVERS_IS_GEN	0x001	/* The Python code has been generated. */
#define	CLASSVERS_HAS_SIGSLOTS	0x002	/* It has signals or slots. */
#define	CLASSVERS_CANNOT_CREATE	0x004	/* It can't be created by Python. */
#define	CLASSVERS_IS_COMPLEX	0x008	/* It is complex. */
#define	CLASSVERS_NO_PUB_DTOR	0x010	/* No public dtor. */
#define	CLASSVERS_IS_DTOR	0x020	/* There is an explicit dtor. */
#define	CLASSVERS_IS_OPAQUE	0x040	/* It is opaque. */
#define	CLASSVERS_IS_NSPACE	0x080	/* It is a namespace. */
#define	CLASSVERS_IS_READY	0x100	/* It is ready to be generated. */

#define	isGenerated(cv)		((cv) -> classversflags & CLASSVERS_IS_GEN)
#define	setIsGenerated(cv)	((cv) -> classversflags |= CLASSVERS_IS_GEN)
#define	hasSigSlots(cv)		((cv) -> classversflags & CLASSVERS_HAS_SIGSLOTS)
#define	setHasSigSlots(cv)	((cv) -> classversflags |= CLASSVERS_HAS_SIGSLOTS)
#define	cannotCreate(cv)	((cv) -> classversflags & CLASSVERS_CANNOT_CREATE)
#define	setCannotCreate(cv)	((cv) -> classversflags |= CLASSVERS_CANNOT_CREATE)
#define	resetCannotCreate(cv)	((cv) -> classversflags &= ~CLASSVERS_CANNOT_CREATE)
#define	isComplex(cv)		((cv) -> classversflags & CLASSVERS_IS_COMPLEX)
#define	setIsComplex(cv)	((cv) -> classversflags |= CLASSVERS_IS_COMPLEX)
#define	noPublicDtor(cv)	((cv) -> classversflags & CLASSVERS_NO_PUB_DTOR)
#define	setNoPublicDtor(cv)	((cv) -> classversflags |= CLASSVERS_NO_PUB_DTOR)
#define	isDtor(cv)		((cv) -> classversflags & CLASSVERS_IS_DTOR)
#define	setIsDtor(cv)		((cv) -> classversflags |= CLASSVERS_IS_DTOR)
#define	isOpaque(cv)		((cv) -> classversflags & CLASSVERS_IS_OPAQUE)
#define	setIsOpaque(cv)		((cv) -> classversflags |= CLASSVERS_IS_OPAQUE)
#define	isNamespace(cv)		((cv) -> classversflags & CLASSVERS_IS_NSPACE)
#define	setIsNamespace(cv)	((cv) -> classversflags |= CLASSVERS_IS_NSPACE)
#define	isReady(cv)		((cv) -> classversflags & CLASSVERS_IS_READY)
#define	setIsReady(cv)		((cv) -> classversflags |= CLASSVERS_IS_READY)


/* Handle interface file flags. */

#define	IFACEFILE_IS_USED	0x01	/* It is used. */
#define	IFACEFILE_HAS_MTYPE	0x02	/* It has a mapped type. */
#define	IFACEFILE_HAS_CVERS	0x04	/* It has a class version. */
#define	IFACEFILE_HAS_REALCVERS	0x08	/* It has a non-namespace class version. */

#define	isUsed(i)		((i) -> ifacefileflags & IFACEFILE_IS_USED)
#define	setIsUsed(i)		((i) -> ifacefileflags |= IFACEFILE_IS_USED)
#define	hasMappedType(i)	((i) -> ifacefileflags & IFACEFILE_HAS_MTYPE)
#define	setHasMappedType(i)	((i) -> ifacefileflags |= IFACEFILE_HAS_MTYPE)
#define	hasClassVers(i)		((i) -> ifacefileflags & IFACEFILE_HAS_CVERS)
#define	setHasClassVers(i)	((i) -> ifacefileflags |= IFACEFILE_HAS_CVERS)
#define	hasRealClassVers(i)	((i) -> ifacefileflags & IFACEFILE_HAS_REALCVERS)
#define	setHasRealClassVers(i)	((i) -> ifacefileflags |= IFACEFILE_HAS_REALCVERS)


/* Handle ctor flags. */

#define	isPublicCtor(c)		((c) -> ctorflags & SECT_IS_PUBLIC)
#define	setIsPublicCtor(c)	((c) -> ctorflags |= SECT_IS_PUBLIC)
#define	isProtectedCtor(c)	((c) -> ctorflags & SECT_IS_PROT)
#define	setIsProtectedCtor(c)	((c) -> ctorflags |= SECT_IS_PROT)
#define	isPrivateCtor(c)	((c) -> ctorflags & SECT_IS_PRIVATE)
#define	setIsPrivateCtor(c)	((c) -> ctorflags |= SECT_IS_PRIVATE)


/* Handle enum flags. */

#define	isProtectedEnum(e)	((e) -> enumflags & SECT_IS_PROT)


/* Handle overload flags. */

#define	OVER_IS_VIRTUAL		0x00010000	/* It is virtual. */
#define	OVER_IS_ABSTRACT	0x00020000	/* It is abstract. */
#define	OVER_IS_CONST		0x00040000	/* It is a const function. */
#define	OVER_IS_STATIC		0x00080000	/* It is a static function. */
#define	OVER_IS_BLOCKING	0x00100000	/* It is a blocking function. */

#define	isPublic(o)		((o) -> overflags & SECT_IS_PUBLIC)
#define	setIsPublic(o)		((o) -> overflags |= SECT_IS_PUBLIC)
#define	isProtected(o)		((o) -> overflags & SECT_IS_PROT)
#define	setIsProtected(o)	((o) -> overflags |= SECT_IS_PROT)
#define	isPrivate(o)		((o) -> overflags & SECT_IS_PRIVATE)
#define	setIsPrivate(o)		((o) -> overflags |= SECT_IS_PRIVATE)
#define	isSlot(o)		((o) -> overflags & SECT_IS_SLOT)
#define	setIsSlot(o)		((o) -> overflags |= SECT_IS_SLOT)
#define	isSignal(o)		((o) -> overflags & SECT_IS_SIGNAL)
#define	setIsSignal(o)		((o) -> overflags |= SECT_IS_SIGNAL)

#define	isVirtual(o)		((o) -> overflags & OVER_IS_VIRTUAL)
#define	setIsVirtual(o)		((o) -> overflags |= OVER_IS_VIRTUAL)
#define	isAbstract(o)		((o) -> overflags & OVER_IS_ABSTRACT)
#define	setIsAbstract(o)	((o) -> overflags |= OVER_IS_ABSTRACT)
#define	isConst(o)		((o) -> overflags & OVER_IS_CONST)
#define	setIsConst(o)		((o) -> overflags |= OVER_IS_CONST)
#define	isStatic(o)		((o) -> overflags & OVER_IS_STATIC)
#define	setIsStatic(o)		((o) -> overflags |= OVER_IS_STATIC)
#define	isBlocking(o)		((o) -> overflags & OVER_IS_BLOCKING)
#define	setIsBlocking(o)	((o) -> overflags |= OVER_IS_BLOCKING)


/* Handle variable flags. */

#define	VAR_IS_STATIC		0x01	/* It is a static variable. */

#define	isStaticVar(v)		((v) -> varflags & VAR_IS_STATIC)
#define	setIsStaticVar(v)	((v) -> varflags |= VAR_IS_STATIC)


/* Handle argument flags. */

#define	ARG_IS_REF		0x01	/* It is a reference. */
#define	ARG_IS_CONST		0x02	/* It is a const. */
#define	ARG_XFERRED		0x04	/* Ownership is transferred. */
#define	ARG_THIS_XFERRED	0x08	/* Ownership of this is transferred. */
#define	ARG_XFERRED_BACK	0x10	/* Ownership is transferred back. */

#define	isReference(a)		((a) -> argflags & ARG_IS_REF)
#define	setIsReference(a)	((a) -> argflags |= ARG_IS_REF)
#define	resetIsReference(a)	((a) -> argflags &= ~ARG_IS_REF)
#define	isConstArg(a)		((a) -> argflags & ARG_IS_CONST)
#define	setIsConstArg(a)	((a) -> argflags |= ARG_IS_CONST)
#define	resetIsConstArg(a)	((a) -> argflags &= ~ARG_IS_CONST)
#define	isTransferred(a)	((a) -> argflags & ARG_XFERRED)
#define	setIsTransferred(a)	((a) -> argflags |= ARG_XFERRED)
#define	isThisTransferred(a)	((a) -> argflags & ARG_THIS_XFERRED)
#define	setIsThisTransferred(a)	((a) -> argflags |= ARG_THIS_XFERRED)
#define	isTransferredBack(a)	((a) -> argflags & ARG_XFERRED_BACK)
#define	setIsTransferredBack(a)	((a) -> argflags |= ARG_XFERRED_BACK)


/* Special Python method IDs. */

#define	SPM_METH_REPR		0x00000001
#define	SPM_METH_STR		0x00000002
#define	SPM_METH_CMP		0x00000004
#define	SPM_METH_HASH		0x00000008
#define	SPM_METH_CALL		0x00000010
#define	SPM_METH_RICH		0x80000000	/* Must be different from SPM_SEQ_*. */

#define	SPM_NUM_ADD		0x00000001
#define	SPM_NUM_SUB		0x00000002
#define	SPM_NUM_MUL		0x00000004
#define	SPM_NUM_DIV		0x00000008
#define	SPM_NUM_MOD		0x00000010
#define	SPM_NUM_DIVMOD		0x00000020
#define	SPM_NUM_POW		0x00000040
#define	SPM_NUM_NEG		0x00000080
#define	SPM_NUM_POS		0x00000100
#define	SPM_NUM_ABS		0x00000200
#define	SPM_NUM_NONZERO		0x00000400
#define	SPM_NUM_INVERT		0x00000800
#define	SPM_NUM_LSHIFT		0x00001000
#define	SPM_NUM_RSHIFT		0x00002000
#define	SPM_NUM_AND		0x00004000
#define	SPM_NUM_XOR		0x00008000
#define	SPM_NUM_OR		0x00010000
#define	SPM_NUM_COERCE		0x00020000	/* Must be different from SPM_SEQ_*. */
#define	SPM_NUM_INT		0x00040000
#define	SPM_NUM_LONG		0x00080000
#define	SPM_NUM_FLOAT		0x00100000
#define	SPM_NUM_OCT		0x00200000
#define	SPM_NUM_HEX		0x00400000
#define	SPM_NUM_IADD		0x00800000
#define	SPM_NUM_ISUB		0x01000000
#define	SPM_NUM_IMUL		0x02000000
#define	SPM_NUM_IDIV		0x04000000
#define	SPM_NUM_IMOD		0x08000000
#define	SPM_NUM_IPOW		0x10000000
#define	SPM_NUM_ILSHIFT		0x20000000
#define	SPM_NUM_IRSHIFT		0x40000000
#define	SPM_NUM_IAND		0x80000000
#define	SPM_NUM_IXOR		0x00000001	/* Use the overspill. */
#define	SPM_NUM_IOR		0x00000002

#define	SPM_SEQ_LEN		0x00000001
#define	SPM_SEQ_CONCAT		0x00000002
#define	SPM_SEQ_REPEAT		0x00000004
#define	SPM_SEQ_GETITEM		0x00000008
#define	SPM_SEQ_SETITEM		0x00000010
#define	SPM_SEQ_GETSLICE	0x00000020
#define	SPM_SEQ_SETSLICE	0x00000040
#define	SPM_SEQ_CONTAINS	0x00000080
#define	SPM_SEQ_ICONCAT		0x00000100
#define	SPM_SEQ_IREPEAT		0x00000200

#define	SPM_MAP_LEN		0x00000001
#define	SPM_MAP_GETITEM		0x00000002
#define	SPM_MAP_SETITEM		0x00000004


/* Argument types. */

typedef enum {
	no_type,
	defined_type,
	class_type,
	struct_type,
	voidptr_type,
	enum_type,
	template_type,
	signal_type,
	rxcon_type,
	rxdis_type,
	slotcon_type,
	slotdis_type,
	ustring_type,
	string_type,
	short_type,
	ushort_type,
	cint_type,
	int_type,
	uint_type,
	long_type,
	ulong_type,
	float_type,
	double_type,
	bool_type,
	array_type,
	uarray_type,
	arraysize_type,
	arrayusize_type,
	mapped_type
} argType;


/* Value types. */

typedef enum {
	qchar_value,
	string_value,
	numeric_value,
	real_value,
	scoped_value,
	fcall_value
} valueType;


/* An exposed function. */

typedef struct _expFuncDef {
	char			*name;		/* The function name. */
	struct _expFuncDef	*next;		/* Next in the list. */
} expFuncDef;


/* A version qualifier. */

typedef struct _versionQual {
	char			*name;		/* The version name. */
	struct _moduleDef	*module;	/* The defining module. */
	int			order;		/* Order if it is a primary. */
	char			*vqcpp;		/* The C++ qualifier. */
	char			*vqpy;		/* The Python qualifier. */
	struct _versionQual	*next;		/* Next in the list. */
} versionQual;


/* A version in time with an optional secondary. */

typedef struct {
	versionQual		*secondary;	/* The optional secondary. */
} versionDef;


/* A scoped name. */

typedef struct _scopedNameDef {
	char			*name;		/* The name. */
	struct _scopedNameDef	*next;		/* Next in the scope list. */
} scopedNameDef;


/* A name. */

typedef struct _nameDef {
	char			*text;		/* The text of the name. */
	struct _moduleDef	*module;	/* The defining module. */
	struct _nameDef		*next;		/* Next in the list. */
} nameDef;


/* A module definition. */

typedef struct _moduleDef {
	nameDef			*name;		/* The module name. */
	char			*file;		/* The filename. */
	int			depth;		/* Depth in the hierachy. */
	versionQual		*timeSlots;	/* The timeline. */
	int			nrTimeSlots;	/* The nr. of versions. */
	versionQual		*required;	/* The required version. */
	struct _moduleDef	*next;		/* Next in the list. */
} moduleDef;


/* A literal code block. */

typedef struct _codeBlock {
	char			*frag;		/* The code itself. */
	char			*filename;	/* The original file. */
	int			linenr;		/* The line in the file. */
	struct _codeBlock	*next;		/* Next in the list. */
} codeBlock;


/* A Makefile template definition. */

typedef struct _mkTemplateDef {
	char			*name;		/* The template name. */
	char			*objext;	/* The object file extension. */
	codeBlock		*templ;		/* The template itself. */
	struct _mkTemplateDef	*next;		/* Next in the list. */
} mkTemplateDef;


/* A special Python method. */

typedef struct {
	char		*name;			/* The method name. */
	int		id;			/* The method ID. */
	int		idxtra;			/* The extra method ID. */
	char		*rettype;		/* The return type. */
	int		nrargs;			/* The number of arguments. */
	unsigned	pyvers;			/* The Python version. */
} specialPyMethod;


/* An entry in a list of defined special Python methods. */

typedef struct _spmDef {
	specialPyMethod	*spm;			/* The actual method detail. */
	versionDef	version;		/* The version qualifier. */
	codeBlock	*code;			/* The implementation code. */
	struct _spmDef	*next;			/* Next in the list. */
} spmDef;


/* A function call. */

typedef struct _fcallDef {
	scopedNameDef		*name;		/* The name. */
	int			nrArgs;		/* The number of arguments. */
	struct _valueDef	*args[MAX_NR_ARGS];	/* The arguments. */
} fcallDef;


/* A value. */

typedef struct _valueDef {
	valueType		vtype;		/* The type. */
	char			vunop;		/* Any unary operator. */
	char			vbinop;		/* Any binary operator. */
	union {
		char		vqchar;		/* Quoted character value. */
		long		vnum;		/* Numeric value. */
		double		vreal;		/* Real value. */
		nameDef		*vstr;		/* String value. */
		scopedNameDef	*vscp;		/* Scoped value. */
		fcallDef	*fcd;		/* Function call. */
	} u;
	struct _valueDef	*next;		/* Next in the expression. */
} valueDef;


/* A member function argument (or result). */

typedef struct {
	argType			atype;		/* The type. */
	int			argflags;	/* The argument flags. */
	int			nrderefs;	/* Nr. of dereferences. */
	valueDef		*defval;	/* The default value. */
	union {
		struct _funcArgs	*sa;	/* If it is a slot. */
		struct _templateDef	*td;	/* If it is a template. */
		struct _scopedNameDef	*snd;	/* If it is a defined type. */
		struct _classVersDef	*cvd;	/* If it is a class. */
		struct _enumDef		*ed;	/* If it is an enum. */
		struct _scopedNameDef	*sname;	/* If it is a struct. */
		struct _mappedTypeDef	*mtd;	/* If it is a mapped type. */
	} u;
} argDef;



/* An interface file definition. */

typedef struct _ifaceFileDef {
	nameDef			*name;		/* The name. */
	scopedNameDef		*fqname;	/* The fully qualified name. */
	moduleDef		*module;	/* The owning module. */
	int			ifacefileflags;	/* The interface file flags. */
	struct _ifaceFileDef	*next;		/* Next in the list. */
} ifaceFileDef;


/* A mapped type. */

typedef struct _mappedTypeDef {
	argDef			type;		/* The type being mapped. */
	ifaceFileDef		*iff;		/* The interface file. */
	versionDef		version;	/* The version qualifier. */
	codeBlock		*hdrcode;	/* Header code. */
	codeBlock		*convfromcode;	/* Convert from C++ code. */
	codeBlock		*convtocode;	/* Convert to C++ code. */
	codeBlock		*canconvtocode;	/* Can convert to C++ code. */
	struct _mappedTypeDef	*next;		/* Next in the list. */
} mappedTypeDef;


/* The arguments to a member function. */

typedef struct _funcArgs {
	int			nrArgs;		/* The number of arguments. */
	argDef			args[MAX_NR_ARGS];	/* The arguments. */
} funcArgs;


/* A template type. */

typedef struct _templateDef {
	scopedNameDef		*fqname;	/* The name. */
	funcArgs		types;		/* The types. */
} templateDef;


/* An or'ed list of versions. */

typedef struct _versionOrList {
	versionDef		version;	/* The version qualifier. */
	struct _versionOrList	*next;		/* Next in the list. */
} versionOrList;


/* A list of function arguments. */

typedef struct _funcArgsList {
	funcArgs		*fa;		/* The arguments. */
	versionOrList		*vol;		/* The version qualifier. */
	struct _funcArgsList	*next;		/* Next in the list. */
} funcArgsList;


/* A typedef definition. */

typedef struct _typedefDef {
	scopedNameDef		*fqname;	/* The fully qualified name. */
	versionDef		version;	/* The version qualifier. */
	struct _classVersDef	*ecvd;		/* The enclosing class. */
	argDef			type;		/* The actual type. */
	struct _typedefDef	*next;		/* Next in the list. */
} typedefDef;


/* A variable definition. */

typedef struct _varDef {
	nameDef			*name;		/* The variable name. */
	scopedNameDef		*fqname;	/* The fully qualified name. */
	versionDef		version;	/* The version qualifier. */
	struct _classVersDef	*ecvd;		/* The enclosing class. */
	moduleDef		*module;	/* The owning module. */
	int			varflags;	/* The variable flags. */
	argDef			type;		/* The actual type. */
	codeBlock		*accessfunc;	/* The access function. */
	struct _varDef		*next;		/* Next in the list. */
} varDef;


/* An overloaded member function definition. */

typedef struct _overDef {
	char			*cppname;	/* The C++ name. */
	int			overflags;	/* The overload flags. */
	struct _memberDef	*common;	/* Common parts. */
	argDef			*result;	/* The result type. */
	funcArgs		args;		/* The arguments. */
	codeBlock		*cppcode;	/* Code in the specification. */
	codeBlock		*virtcode;	/* Virtual handler code. */
	versionDef		version;	/* The version qualifier. */
	char			*prehook;	/* The pre-hook name. */
	char			*posthook;	/* The post-hook name. */
	struct _overDef		*next;		/* Next in the list. */
} overDef;


/* An overloaded constructor definition. */

typedef struct _ctorDef {
	int			ctorflags;	/* The ctor flags. */
	funcArgs		args;		/* The arguments. */
	codeBlock		*cppcode;	/* Code in the specification. */
	versionDef		version;	/* The version qualifier. */
	struct _ctorDef		*next;		/* Next in the list. */
} ctorDef;


/* An enumerated type value definition. */

typedef struct _enumValueDef {
	nameDef			*name;		/* The value name. */
	struct _enumValueDef	*next;		/* Next in the list. */
} enumValueDef;


/* An enumerated type definition. */

typedef struct _enumDef {
	int			enumflags;	/* The enum flags. */
	scopedNameDef		*fqname;	/* The name (may be NULL). */
	struct _classVersDef	*ecvd;		/* The enclosing class. */
	moduleDef		*module;	/* The owning module. */
	enumValueDef		*values;	/* The list of values. */
	versionDef		version;	/* The version qualifier. */
	struct _enumDef		*next;		/* Next in the list. */
} enumDef;


/* An member function definition. */

typedef struct _memberDef {
	nameDef			*pyname;	/* The Python name. */
	moduleDef		*module;	/* The owning module. */
	struct _memberDef	*next;		/* Next in the list. */
} memberDef;


/* A list of visible member functions. */

typedef struct _visibleList {
	memberDef		*m;		/* The member definition. */
	struct _classVersDef	*cv;		/* The class version. */
	struct _visibleList	*next;		/* Next in the list. */
} visibleList;


/* An entry in a linked class version list. */

typedef struct _classVersList {
	struct _classVersDef	*cv;		/* The class version itself. */
	struct _classVersList	*next;		/* Next in the list. */
} classVersList;


/* An entry in a linked interface file list. */

typedef struct _ifaceFileList {
	struct _ifaceFileDef	*iff;		/* The interface file itself. */
	struct _ifaceFileList	*next;		/* Next in the list. */
} ifaceFileList;


/* An entry in a linked class list. */

typedef struct _classList {
	struct _classDef	*c;		/* The class itself. */
	struct _classList	*next;		/* Next in the list. */
} classList;


/* A virtual overload definition. */

typedef struct _virtOverDef {
	overDef			*o;		/* The overload. */
	struct _classVersDef	*nearc;		/* The nearest class. */
	struct _classVersDef	*farc;		/* The farthest class. */
	struct _virtOverDef	*next;		/* Next in the list. */
} virtOverDef;


/* A list of virtuals for a particular version. */

typedef struct _virtVersDef {
	virtOverDef		*vo;		/* The overloads. */
	struct _virtVersDef	*next;		/* Next in the list. */
} virtVersDef;


/* A versioned class definition. */

typedef struct _classVersDef {
	int			classversflags;	/* The class version flags. */
	struct _classDef	*common;	/* Common to all versions. */
	struct _classVersDef	*ecvd;		/* The enclosing scope. */
	classList		*supers;	/* The parent classes. */
	classVersList		*hierachy;	/* The super-class hierachy. */
	versionDef		version;	/* The version qualifier. */
	ctorDef			*ctors;		/* The constructors. */
	codeBlock		*dtorcode;	/* Handwritten dtor code. */
	memberDef		*members;	/* The member functions. */
	overDef			*overs;		/* The overloads. */
	virtVersDef		*vmembers;	/* The virtual members. */
	visibleList		*visible;	/* The visible members. */
	codeBlock		*cppcode;	/* Class C++ code. */
	codeBlock		*hdrcode;	/* Class header code. */
	codeBlock		*convtosubcode;	/* Convert to sub C++ code. */
	codeBlock		*convtocode;	/* Convert to C++ code. */
	codeBlock		*canconvtocode;	/* Can convert to C++ code. */
	spmDef			*spms;		/* Special Python methods. */
	int			combmeth;	/* Combined methods. */
	int			combmethx;	/* Combined methods. */
	int			combnummeth;	/* Combined numeric methods. */
	int			combnummethx;	/* Combined numeric methods. */
	int			combseqmeth;	/* Combined sequence methods. */
	int			combseqmethx;	/* Combined sequence methods. */
	int			combmapmeth;	/* Combined mapping methods. */
	int			combmapmethx;	/* Combined mapping methods. */
	int			combcmpmeth;	/* Combined compare methods. */
	int			combcmpmethx;	/* Combined compare methods. */
	ifaceFileList		*used;		/* Interface files used. */
	struct _classVersDef	*next;		/* Next in the list. */
} classVersDef;


/* A class definition. */

typedef struct _classDef {
	ifaceFileDef		*iff;		/* The interface file. */
	int			classnr;	/* The class number. */
	struct _classDef	*next;		/* Next in the list. */
} classDef;


/* The parse tree corresponding to the specification file. */

typedef struct {
	moduleDef		*moduleList;	/* The module list. */
	moduleDef		*module;	/* This module. */
	char			*cppmname;	/* The C++ module name. */
	nameDef			*namecache;	/* The name cache. */
	versionQual		*secondaries;	/* The secondary versions. */
	ifaceFileDef		*ifacefiles;	/* The list of interface files. */
	classDef		*classes;	/* The list of classes. */
	classVersDef		*classversions;	/* The list of class versions. */
	mappedTypeDef		*mappedtypes;	/* The mapped types. */
	ifaceFileList		*used;		/* Interface files used. */
	int			qobjclass;	/* QObject class, -1 if none. */
	expFuncDef		*exposed;	/* Exposed functions. */
	enumDef			*enums;		/* List of enums. */
	varDef			*vars;		/* List of variables. */
	memberDef		*othfuncs;	/* List of other functions. */
	overDef			*overs;		/* Global overloads. */
	typedefDef		*typedefs;	/* List of typedefs. */
	codeBlock		*copying;	/* Software license. */
	codeBlock		*hdrcode;	/* Header code. */
	codeBlock		*versioncode;	/* Version code. */
	codeBlock		*exphdrcode;	/* Exported header code. */
	codeBlock		*cppcode;	/* Global C++ code. */
	codeBlock		*prepycode;	/* Global pre-Python code. */
	codeBlock		*pycode;	/* Global Python code. */
	codeBlock		*docs;		/* Documentation. */
	mkTemplateDef		*mktemplates;	/* The Makefile templates. */
	funcArgsList		*sigargs;	/* The list of signal arguments. */
	int			sigslots;	/* Set if signals or slots are used. */
} sipSpec;


/* A list of strings. */

typedef struct _stringList {
	char			*s;		/* The string. */
	struct _stringList	*next;		/* The next in the list. */
} stringList;


/* File specific context information for the parser. */

typedef struct _parserContext {
	int			ifdepth;	/* The depth of nested if's. */
	moduleDef		*prevmod;	/* The previous module. */
	int			inherit;	/* Set to inherit the timeline. */
} parserContext;


char *sipVersion;		/* The version of SIP. */
stringList *includeDirList;	/* The include directory list for SIP files. */


void parse(sipSpec *,FILE *,char *,char *,stringList *);
void parserEOF(char *,parserContext *);
void transform(sipSpec *);
void generateCode(sipSpec *,char *,stringList *,char *,char *);
void fatal(char *,...);
void fatalVersion(sipSpec *,versionDef *);
void fatalScopedName(scopedNameDef *);
void setInputFile(FILE *,char *,parserContext *);
void *sipMalloc(size_t);
char *sipStrdup(char *);
char *concat(char *,...);
void append(char **,char *);
void addToUsedList(ifaceFileList **,ifaceFileDef *);
void orVersionQual(sipSpec *,versionOrList **,versionDef *);
int versionsOverlap(versionDef *,versionDef *);
int sameOverload(overDef *,overDef *,int);
int sameFuncArgs(funcArgs *,funcArgs *,int);
int sameScopedName(scopedNameDef *,scopedNameDef *);
int sameArgType(argDef *,argDef *,int);
int sameBaseType(argDef *,argDef *,int);
char *scopedNameTail(scopedNameDef *);
scopedNameDef *text2scopePart(char *);
scopedNameDef *copyScopedName(scopedNameDef *);
void appendScopedName(scopedNameDef **,scopedNameDef *);
void freeScopedName(scopedNameDef *);


/* These are only here because bison publically references them. */

/* Represent a set of option flags. */

#define	MAX_NR_FLAGS	5

typedef enum {
	bool_flag,
	string_flag,
	name_flag
} flagType;

typedef struct {
	char		*fname;			/* The flag name. */
	flagType	ftype;			/* The flag type. */
	union {					/* The flag value. */
		char	*sval;			/* A string value. */
	} fvalue;
} optFlag;

typedef struct {
	int		nrFlags;		/* The number of flags. */
	optFlag		flags[MAX_NR_FLAGS];	/* Each flag. */
} optFlags;

typedef struct {
	int		lowidx;			/* The primary lower index. */
	int		uppidx;			/* The primary upper index. */
	versionQual	*secondary;		/* The optional secondary. */
} versionRange;

#endif