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
|
/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
* swigmod.h
*
* Main header file for SWIG modules.
* ----------------------------------------------------------------------------- */
/* $Id$ */
#ifndef SWIG_SWIGMOD_H_
#define SWIG_SWIGMOD_H_
#include "swig.h"
#include "preprocessor.h"
#include "swigwarn.h"
#if !defined(HAVE_BOOL)
typedef int bool;
#define true ((bool)1)
#define false ((bool)0)
#endif
#define NOT_VIRTUAL 0
#define PLAIN_VIRTUAL 1
#define PURE_VIRTUAL 2
extern String *input_file;
extern int line_number;
extern int start_line;
extern int CPlusPlus; // C++ mode
extern int Extend; // Extend mode
extern int Verbose;
extern int IsVirtual;
extern int ImportMode;
extern int NoExcept; // -no_except option
extern int Abstract; // abstract base class
extern int SmartPointer; // smart pointer methods being emitted
extern int SwigRuntime;
/* Overload "argc" and "argv" */
extern String *argv_template_string;
extern String *argc_template_string;
/* Miscellaneous stuff */
#define tab2 " "
#define tab4 " "
#define tab8 " "
class Dispatcher {
public:
Dispatcher ():cplus_mode(PUBLIC) {
}
virtual ~ Dispatcher () {
}
virtual int emit_one(Node *n);
virtual int emit_children(Node *n);
virtual int defaultHandler(Node *n);
/* Top of the parse tree */
virtual int top(Node *n) = 0;
/* SWIG directives */
virtual int applyDirective(Node *n);
virtual int clearDirective(Node *n);
virtual int constantDirective(Node *n);
virtual int extendDirective(Node *n);
virtual int fragmentDirective(Node *n);
virtual int importDirective(Node *n);
virtual int includeDirective(Node *n);
virtual int insertDirective(Node *n);
virtual int moduleDirective(Node *n);
virtual int nativeDirective(Node *n);
virtual int pragmaDirective(Node *n);
virtual int typemapDirective(Node *n);
virtual int typemapitemDirective(Node *n);
virtual int typemapcopyDirective(Node *n);
virtual int typesDirective(Node *n);
/* C/C++ parsing */
virtual int cDeclaration(Node *n);
virtual int externDeclaration(Node *n);
virtual int enumDeclaration(Node *n);
virtual int enumvalueDeclaration(Node *n);
virtual int enumforwardDeclaration(Node *n);
virtual int classDeclaration(Node *n);
virtual int classforwardDeclaration(Node *n);
virtual int constructorDeclaration(Node *n);
virtual int destructorDeclaration(Node *n);
virtual int accessDeclaration(Node *n);
virtual int usingDeclaration(Node *n);
virtual int namespaceDeclaration(Node *n);
virtual int templateDeclaration(Node *n);
enum AccessMode { PUBLIC, PRIVATE, PROTECTED };
protected:
AccessMode cplus_mode;
};
/* ----------------------------------------------------------------------------
* class language:
*
* This class defines the functions that need to be supported by the
* scripting language being used. The translator calls these virtual
* functions to output different types of code for different languages.
* ------------------------------------------------------------------------- */
class Language:public Dispatcher {
public:
Language();
virtual ~Language();
virtual int emit_one(Node *n);
/* Parse command line options */
virtual void main(int argc, char *argv[]);
/* Top of the parse tree */
virtual int top(Node *n);
/* SWIG directives */
virtual int applyDirective(Node *n);
virtual int clearDirective(Node *n);
virtual int constantDirective(Node *n);
virtual int extendDirective(Node *n);
virtual int fragmentDirective(Node *n);
virtual int importDirective(Node *n);
virtual int includeDirective(Node *n);
virtual int insertDirective(Node *n);
virtual int moduleDirective(Node *n);
virtual int nativeDirective(Node *n);
virtual int pragmaDirective(Node *n);
virtual int typemapDirective(Node *n);
virtual int typemapcopyDirective(Node *n);
virtual int typesDirective(Node *n);
/* C/C++ parsing */
virtual int cDeclaration(Node *n);
virtual int externDeclaration(Node *n);
virtual int enumDeclaration(Node *n);
virtual int enumvalueDeclaration(Node *n);
virtual int enumforwardDeclaration(Node *n);
virtual int classDeclaration(Node *n);
virtual int classforwardDeclaration(Node *n);
virtual int constructorDeclaration(Node *n);
virtual int destructorDeclaration(Node *n);
virtual int accessDeclaration(Node *n);
virtual int namespaceDeclaration(Node *n);
virtual int usingDeclaration(Node *n);
/* Function handlers */
virtual int functionHandler(Node *n);
virtual int globalfunctionHandler(Node *n);
virtual int memberfunctionHandler(Node *n);
virtual int staticmemberfunctionHandler(Node *n);
virtual int callbackfunctionHandler(Node *n);
/* Variable handlers */
virtual int variableHandler(Node *n);
virtual int globalvariableHandler(Node *n);
virtual int membervariableHandler(Node *n);
virtual int staticmembervariableHandler(Node *n);
/* C++ handlers */
virtual int memberconstantHandler(Node *n);
virtual int constructorHandler(Node *n);
virtual int copyconstructorHandler(Node *n);
virtual int destructorHandler(Node *n);
virtual int classHandler(Node *n);
/* Miscellaneous */
virtual int typedefHandler(Node *n);
/* Low-level code generation */
virtual int constantWrapper(Node *n);
virtual int variableWrapper(Node *n);
virtual int functionWrapper(Node *n);
virtual int nativeWrapper(Node *n);
/* C++ director class generation */
virtual int classDirector(Node *n);
virtual int classDirectorInit(Node *n);
virtual int classDirectorEnd(Node *n);
virtual int unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_director, int &virtual_destructor, int protectedbase = 0);
virtual int classDirectorConstructor(Node *n);
virtual int classDirectorDefaultConstructor(Node *n);
virtual int classDirectorMethod(Node *n, Node *parent, String *super);
virtual int classDirectorConstructors(Node *n);
virtual int classDirectorDestructor(Node *n);
virtual int classDirectorMethods(Node *n);
virtual int classDirectorDisown(Node *n);
/* Miscellaneous */
virtual int validIdentifier(String *s); /* valid identifier? */
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
virtual void dumpSymbols();
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
virtual Node *classLookup(SwigType *s); /* Class lookup */
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
virtual int is_assignable(Node *n); /* Is variable assignable? */
virtual String *runtimeCode(); /* returns the language specific runtime code */
virtual String *defaultExternalRuntimeFilename(); /* the default filename for the external runtime */
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm); /* Language specific special variable substitutions for $typemap() */
/* Runtime is C++ based, so extern "C" header section */
void enable_cplus_runtime_mode();
/* Returns the cplus_runtime mode */
int cplus_runtime_mode();
/* Allow director related code generation */
void allow_directors(int val = 1);
/* Return true if directors are enabled */
int directorsEnabled() const;
/* Allow director protected members related code generation */
void allow_dirprot(int val = 1);
/* Allow all protected members code generation (for directors) */
void allow_allprotected(int val = 0);
/* Returns the dirprot mode */
int dirprot_mode() const;
/* Check if the non public constructor is needed (for directors) */
int need_nonpublic_ctor(Node *n);
/* Check if the non public member is needed (for directors) */
int need_nonpublic_member(Node *n);
/* Set none comparison string */
void setSubclassInstanceCheck(String *s);
/* Set overload variable templates argc and argv */
void setOverloadResolutionTemplates(String *argc, String *argv);
/* Language instance is a singleton - get instance */
static Language* instance();
protected:
/* Allow multiple-input typemaps */
void allow_multiple_input(int val = 1);
/* Allow overloaded functions */
void allow_overloading(int val = 1);
/* Wrapping class query */
int is_wrapping_class();
/* Return the node for the current class */
Node *getCurrentClass() const;
/* Return C++ mode */
int getCPlusMode() const;
/* Return the real name of the current class */
String *getClassName() const;
/* Return the classes hash */
Hash *getClassHash() const;
/* Return the current class prefix */
String *getClassPrefix() const;
/* Fully qualified type name to use */
String *getClassType() const;
/* Return true if the current method is part of a smart-pointer */
int is_smart_pointer() const;
/* Some language modules require additional wrappers for virtual methods not declared in sub-classes */
virtual bool extraDirectorProtectedCPPMethodsRequired() const;
/* Director subclass comparison test */
String *none_comparison;
/* Director constructor "template" code */
String *director_ctor_code;
/* Director 'protected' constructor "template" code */
String *director_prot_ctor_code;
/* Director allows multiple inheritance */
int director_multiple_inheritance;
/* Director language module */
int director_language;
private:
Hash *symtabs; /* symbol tables */
Hash *classtypes;
Hash *enumtypes;
int overloading;
int multiinput;
int cplus_runtime;
int directors;
static Language *this_;
};
int SWIG_main(int, char **, Language *);
void emit_parameter_variables(ParmList *l, Wrapper *f);
void emit_return_variable(Node *n, SwigType *rt, Wrapper *f);
void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */
void SWIG_config_file(const_String_or_char_ptr );
const String *SWIG_output_directory();
void SWIG_config_cppext(const char *ext);
void Swig_print_xml(Node *obj, String *filename);
/* get the list of generated files */
List *SWIG_output_files();
void SWIG_library_directory(const char *);
int emit_num_arguments(ParmList *);
int emit_num_required(ParmList *);
int emit_isvarargs(ParmList *);
void emit_attach_parmmaps(ParmList *, Wrapper *f);
void emit_mark_varargs(ParmList *l);
String *emit_action(Node *n);
int emit_action_code(Node *n, String *wrappercode, String *action);
void Swig_overload_check(Node *n);
String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *);
String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *);
String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *);
SwigType *cplus_value_type(SwigType *t);
/* directors.cxx start */
String *Swig_csuperclass_call(String *base, String *method, ParmList *l);
String *Swig_class_declaration(Node *n, String *name);
String *Swig_class_name(Node *n);
String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms);
String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values);
String *Swig_director_declaration(Node *n);
void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f);
/* directors.cxx end */
extern "C" {
void SWIG_typemap_lang(const char *);
typedef Language *(*ModuleFactory) (void);
}
void Swig_register_module(const char *name, ModuleFactory fac);
ModuleFactory Swig_find_module(const char *name);
/* Utilities */
int is_public(Node *n);
int is_private(Node *n);
int is_protected(Node *n);
int is_member_director(Node *parentnode, Node *member);
int is_member_director(Node *member);
int is_non_virtual_protected_access(Node *n); /* Check if the non-virtual protected members are required (for directors) */
int use_naturalvar_mode(Node *n);
void Wrapper_virtual_elimination_mode_set(int);
void Wrapper_fast_dispatch_mode_set(int);
void Wrapper_cast_dispatch_mode_set(int);
void Wrapper_naturalvar_mode_set(int);
void clean_overloaded(Node *n);
/* Contracts */
void Swig_contracts(Node *n);
void Swig_contract_mode_set(int flag);
int Swig_contract_mode_get();
/* Browser */
void Swig_browser(Node *n, int);
void Swig_default_allocators(Node *n);
void Swig_process_types(Node *n);
#endif
|