PageRenderTime 39ms CodeModel.GetById 1ms app.highlight 32ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Source/Swig/swig.h

#
C++ Header | 425 lines | 321 code | 64 blank | 40 comment | 0 complexity | b0ac461ad58d69dcdce490a0735fad47 MD5 | raw file
  1/* ----------------------------------------------------------------------------- 
  2 * This file is part of SWIG, which is licensed as a whole under version 3 
  3 * (or any later version) of the GNU General Public License. Some additional
  4 * terms also apply to certain portions of SWIG. The full details of the SWIG
  5 * license and copyrights can be found in the LICENSE and COPYRIGHT files
  6 * included with the SWIG source code as distributed by the SWIG developers
  7 * and at http://www.swig.org/legal.html.
  8 *
  9 * swig.h
 10 *
 11 * Header file for the SWIG core.
 12 * ----------------------------------------------------------------------------- */
 13
 14#ifndef SWIGCORE_H_
 15#define SWIGCORE_H_
 16
 17#ifndef MACSWIG
 18#include "swigconfig.h"
 19#endif
 20
 21#include <stdio.h>
 22#include <string.h>
 23#include <stdlib.h>
 24#include <assert.h>
 25
 26#ifdef __cplusplus
 27extern "C" {
 28#endif
 29
 30#include "doh.h"
 31
 32/* Status codes */
 33
 34#define SWIG_OK         1
 35#define SWIG_ERROR      0
 36#define SWIG_NOWRAP     0
 37
 38/* Global macros */
 39#define NSPACE_SEPARATOR "." /* Namespace separator for the nspace feature - this should be changed to a target language configurable variable */
 40#define NSPACE_TODO 0 /* Languages that still need to implement and test the nspace feature use this */
 41
 42/* Short names for common data types */
 43
 44  typedef DOH String;
 45  typedef DOH Hash;
 46  typedef DOH List;
 47  typedef DOH String_or_char;
 48  typedef DOH File;
 49  typedef DOH Parm;
 50  typedef DOH ParmList;
 51  typedef DOH Node;
 52  typedef DOH Symtab;
 53  typedef DOH Typetab;
 54  typedef DOH SwigType;
 55
 56/* --- Legacy DataType interface.  These type codes are provided solely 
 57       for backwards compatibility with older modules --- */
 58
 59/* --- The ordering of type values is used to determine type-promotion 
 60       in the parser.  Do not change */
 61
 62/* Numeric types */
 63
 64#define   T_BOOL       1
 65#define   T_SCHAR      2
 66#define   T_UCHAR      3
 67#define   T_SHORT      4
 68#define   T_USHORT     5
 69#define   T_ENUM       6
 70#define   T_INT        7
 71#define   T_UINT       8
 72#define   T_LONG       9
 73#define   T_ULONG      10
 74#define   T_LONGLONG   11
 75#define   T_ULONGLONG  12
 76#define   T_FLOAT      20
 77#define   T_DOUBLE     21
 78#define   T_LONGDOUBLE 22
 79#define   T_FLTCPLX    23
 80#define   T_DBLCPLX    24
 81#define   T_NUMERIC    25
 82
 83#define   T_COMPLEX    T_DBLCPLX
 84
 85/* non-numeric */
 86
 87#define   T_CHAR       29
 88#define   T_WCHAR      30
 89#define   T_USER       31
 90#define   T_VOID       32
 91#define   T_STRING     33
 92#define   T_POINTER    34
 93#define   T_REFERENCE  35
 94#define   T_ARRAY      36
 95#define   T_FUNCTION   37
 96#define   T_MPOINTER   38
 97#define   T_VARARGS    39
 98#define   T_SYMBOL     98
 99#define   T_ERROR      99
100
101
102/* --- File interface --- */
103
104#include "swigfile.h"
105
106/* --- Command line parsing --- */
107
108#include "swigopt.h"
109
110/* --- Scanner Interface --- */
111
112#include "swigscan.h"
113
114/* --- Functions for manipulating the string-based type encoding --- */
115
116  extern SwigType *NewSwigType(int typecode);
117  extern SwigType *SwigType_del_element(SwigType *t);
118  extern SwigType *SwigType_add_pointer(SwigType *t);
119  extern SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr qual);
120  extern SwigType *SwigType_del_memberpointer(SwigType *t);
121  extern SwigType *SwigType_del_pointer(SwigType *t);
122  extern SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size);
123  extern SwigType *SwigType_del_array(SwigType *t);
124  extern SwigType *SwigType_pop_arrays(SwigType *t);
125  extern SwigType *SwigType_add_reference(SwigType *t);
126  extern SwigType *SwigType_del_reference(SwigType *t);
127  extern SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual);
128  extern SwigType *SwigType_del_qualifier(SwigType *t);
129  extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
130  extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
131  extern SwigType *SwigType_pop_function(SwigType *t);
132  extern ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node);
133  extern List *SwigType_split(const SwigType *t);
134  extern String *SwigType_pop(SwigType *t);
135  extern void SwigType_push(SwigType *t, String *s);
136  extern List *SwigType_parmlist(const SwigType *p);
137  extern String *SwigType_parm(const SwigType *p);
138  extern String *SwigType_str(const SwigType *s, const_String_or_char_ptr id);
139  extern String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id);
140  extern String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr id);
141  extern String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr id);
142  extern String *SwigType_manglestr(const SwigType *t);
143  extern SwigType *SwigType_ltype(const SwigType *t);
144  extern int SwigType_ispointer(const SwigType *t);
145  extern int SwigType_ispointer_return(const SwigType *t);
146  extern int SwigType_isfunctionpointer(const SwigType *t);
147  extern int SwigType_ismemberpointer(const SwigType *t);
148  extern int SwigType_isreference(const SwigType *t);
149  extern int SwigType_isreference_return(const SwigType *t);
150  extern int SwigType_isarray(const SwigType *t);
151  extern int SwigType_prefix_is_simple_1D_array(const SwigType *t);
152  extern int SwigType_isfunction(const SwigType *t);
153  extern int SwigType_isqualifier(const SwigType *t);
154  extern int SwigType_isconst(const SwigType *t);
155  extern int SwigType_issimple(const SwigType *t);
156  extern int SwigType_ismutable(const SwigType *t);
157  extern int SwigType_isvarargs(const SwigType *t);
158  extern int SwigType_istemplate(const SwigType *t);
159  extern int SwigType_isenum(const SwigType *t);
160  extern int SwigType_check_decl(const SwigType *t, const_String_or_char_ptr decl);
161  extern SwigType *SwigType_strip_qualifiers(const SwigType *t);
162  extern SwigType *SwigType_strip_single_qualifier(const SwigType *t);
163  extern SwigType *SwigType_functionpointer_decompose(SwigType *t);
164  extern String *SwigType_base(const SwigType *t);
165  extern String *SwigType_namestr(const SwigType *t);
166  extern String *SwigType_templateprefix(const SwigType *t);
167  extern String *SwigType_templatesuffix(const SwigType *t);
168  extern String *SwigType_istemplate_templateprefix(const SwigType *t);
169  extern String *SwigType_istemplate_only_templateprefix(const SwigType *t);
170  extern String *SwigType_templateargs(const SwigType *t);
171  extern String *SwigType_prefix(const SwigType *t);
172  extern int SwigType_array_ndim(const SwigType *t);
173  extern String *SwigType_array_getdim(const SwigType *t, int n);
174  extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep);
175  extern SwigType *SwigType_array_type(const SwigType *t);
176  extern SwigType *SwigType_default_create(const SwigType *ty);
177  extern SwigType *SwigType_default_deduce(const SwigType *t);
178  extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
179  extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t);
180  extern SwigType *SwigType_alttype(const SwigType *t, int ltmap);
181
182/* --- Type-system managment --- */
183  extern void SwigType_typesystem_init(void);
184  extern int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name);
185  extern int SwigType_typedef_class(const_String_or_char_ptr name);
186  extern int SwigType_typedef_using(const_String_or_char_ptr qname);
187  extern void SwigType_inherit(String *subclass, String *baseclass, String *cast, String *conversioncode);
188  extern int SwigType_issubtype(const SwigType *subtype, const SwigType *basetype);
189  extern void SwigType_scope_alias(String *aliasname, Typetab *t);
190  extern void SwigType_using_scope(Typetab *t);
191  extern void SwigType_new_scope(const_String_or_char_ptr name);
192  extern void SwigType_inherit_scope(Typetab *scope);
193  extern Typetab *SwigType_pop_scope(void);
194  extern Typetab *SwigType_set_scope(Typetab *h);
195  extern void SwigType_print_scope(void);
196  extern SwigType *SwigType_typedef_resolve(const SwigType *t);
197  extern SwigType *SwigType_typedef_resolve_all(const SwigType *t);
198  extern SwigType *SwigType_typedef_qualified(const SwigType *t);
199  extern int SwigType_istypedef(const SwigType *t);
200  extern int SwigType_isclass(const SwigType *t);
201  extern void SwigType_attach_symtab(Symtab *syms);
202  extern void SwigType_remember(const SwigType *t);
203  extern void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata);
204  extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata);
205  extern void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *);
206  extern void SwigType_emit_type_table(File *f_headers, File *f_table);
207  extern int SwigType_type(const SwigType *t);
208
209/* --- Symbol table module --- */
210
211  extern void Swig_symbol_print_tables(Symtab *symtab);
212  extern void Swig_symbol_print_tables_summary(void);
213  extern void Swig_symbol_print_symbols(void);
214  extern void Swig_symbol_print_csymbols(void);
215  extern void Swig_symbol_init(void);
216  extern void Swig_symbol_setscopename(const_String_or_char_ptr name);
217  extern String *Swig_symbol_getscopename(void);
218  extern String *Swig_symbol_qualifiedscopename(Symtab *symtab);
219  extern String *Swig_symbol_qualified_language_scopename(Symtab *symtab);
220  extern Symtab *Swig_symbol_newscope(void);
221  extern Symtab *Swig_symbol_setscope(Symtab *);
222  extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname);
223  extern Symtab *Swig_symbol_global_scope(void);
224  extern Symtab *Swig_symbol_current(void);
225  extern Symtab *Swig_symbol_popscope(void);
226  extern Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *node);
227  extern void Swig_symbol_cadd(const_String_or_char_ptr symname, Node *node);
228  extern Node *Swig_symbol_clookup(const_String_or_char_ptr symname, Symtab *tab);
229  extern Node *Swig_symbol_clookup_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *));
230  extern Symtab *Swig_symbol_cscope(const_String_or_char_ptr symname, Symtab *tab);
231  extern Node *Swig_symbol_clookup_local(const_String_or_char_ptr symname, Symtab *tab);
232  extern Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *));
233  extern String *Swig_symbol_qualified(Node *node);
234  extern Node *Swig_symbol_isoverloaded(Node *node);
235  extern void Swig_symbol_remove(Node *node);
236  extern void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *tab);
237  extern void Swig_symbol_inherit(Symtab *tab);
238  extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab);
239  extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
240  extern SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab);
241
242  extern ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
243  extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
244  extern SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab);
245
246/* --- Parameters and Parameter Lists --- */
247
248#include "swigparm.h"
249
250extern String    *ParmList_errorstr(ParmList *);
251extern int        ParmList_is_compactdefargs(ParmList *p);
252
253/* --- Parse tree support --- */
254
255#include "swigtree.h"
256
257/* -- Wrapper function Object */
258
259#include "swigwrap.h"
260
261/* --- Naming functions --- */
262
263  extern void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format);
264  extern void Swig_name_unregister(const_String_or_char_ptr method);
265  extern String *Swig_name_mangle(const_String_or_char_ptr s);
266  extern String *Swig_name_wrapper(const_String_or_char_ptr fname);
267  extern String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername);
268  extern String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname);
269  extern String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname);
270  extern String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
271  extern String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
272  extern String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
273  extern String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
274
275  extern void Swig_naming_init(void);
276  extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
277  extern Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl);
278  extern void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *namewrn, ParmList *declaratorparms);
279  extern void Swig_name_inherit(String *base, String *derived);
280  extern int Swig_need_protected(Node *n);
281  extern int Swig_need_name_warning(Node *n);
282  extern int Swig_need_redefined_warn(Node *a, Node *b, int InClass);
283
284  extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname);
285  extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl);
286  extern String *Swig_name_str(Node *n);
287  extern String *Swig_name_decl(Node *n);
288  extern String *Swig_name_fulldecl(Node *n);
289
290/* --- parameterized rename functions --- */
291
292  extern void Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object);
293  extern DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *decl);
294  extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived);
295  extern void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl, Node *n);
296  extern void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, String *value, Hash *featureattribs);
297
298/* --- Misc --- */
299  extern char *Swig_copy_string(const char *c);
300  extern void Swig_set_fakeversion(const char *version);
301  extern const char *Swig_package_version(void);
302  extern void Swig_banner(File *f);
303  extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar);
304  extern String *Swig_strip_c_comments(const String *s);
305  extern String *Swig_new_subdirectory(String *basedirectory, String *subdirectory);
306  extern void Swig_filename_correct(String *filename);
307  extern String *Swig_filename_escape(String *filename);
308  extern void Swig_filename_unescape(String *filename);
309  extern String *Swig_string_escape(String *s);
310  extern String *Swig_string_mangle(const String *s);
311  extern void Swig_scopename_split(const String *s, String **prefix, String **last);
312  extern String *Swig_scopename_prefix(const String *s);
313  extern String *Swig_scopename_last(const String *s);
314  extern String *Swig_scopename_first(const String *s);
315  extern String *Swig_scopename_suffix(const String *s);
316  extern int Swig_scopename_check(const String *s);
317  extern String *Swig_string_lower(String *s);
318  extern String *Swig_string_upper(String *s);
319  extern String *Swig_string_title(String *s);
320  extern String *Swig_pcre_version(void);
321  extern void Swig_init(void);
322  extern int Swig_value_wrapper_mode(int mode);
323
324  typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat;
325
326  extern void Swig_warning(int num, const_String_or_char_ptr filename, int line, const char *fmt, ...);
327  extern void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...);
328  extern int Swig_error_count(void);
329  extern void Swig_error_silent(int s);
330  extern void Swig_warnfilter(const_String_or_char_ptr wlist, int val);
331  extern void Swig_warnall(void);
332  extern int Swig_warn_count(void);
333  extern void Swig_error_msg_format(ErrorMessageFormat format);
334  extern void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...);
335  extern String *Swig_stringify_with_location(DOH *object);
336
337/* --- C Wrappers --- */
338  extern void Swig_cresult_name_set(const char *new_name);
339  extern const char *Swig_cresult_name(void);
340  extern String *Swig_cparm_name(Parm *p, int i);
341  extern String *Swig_wrapped_var_type(SwigType *t, int varcref);
342  extern int Swig_cargs(Wrapper *w, ParmList *l);
343  extern String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl);
344
345  extern String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms);
346  extern String *Swig_cconstructor_call(const_String_or_char_ptr name);
347  extern String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms);
348  extern String *Swig_unref_call(Node *n);
349  extern String *Swig_ref_call(Node *n, const String *lname);
350  extern String *Swig_cdestructor_call(Node *n);
351  extern String *Swig_cppdestructor_call(Node *n);
352  extern String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref);
353  extern String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref);
354
355  extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self);
356
357/* --- Transformations --- */
358
359  extern int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director);
360  extern int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
361  extern int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int cplus, int flags);
362  extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
363  extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
364  extern int Swig_VargetToFunction(Node *n, int flags);
365  extern int Swig_VarsetToFunction(Node *n, int flags);
366
367#define  CWRAP_EXTEND                 0x01
368#define  CWRAP_SMART_POINTER          0x02
369#define  CWRAP_NATURAL_VAR            0x04
370#define  CWRAP_DIRECTOR_ONE_CALL      0x08
371#define  CWRAP_DIRECTOR_TWO_CALLS     0x10
372#define  CWRAP_ALL_PROTECTED_ACCESS   0x20
373#define  CWRAP_SMART_POINTER_OVERLOAD 0x40
374
375/* --- Director Helpers --- */
376  extern Node *Swig_methodclass(Node *n);
377  extern int Swig_directorclass(Node *n);
378  extern Node *Swig_directormap(Node *n, String *type);
379
380/* --- Legacy Typemap API (somewhat simplified, ha!) --- */
381
382  extern void Swig_typemap_init(void);
383  extern void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *pattern, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs);
384  extern int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcpattern, ParmList *pattern);
385  extern void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *pattern);
386  extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat);
387  extern void Swig_typemap_clear_apply(ParmList *pattern);
388  extern void Swig_typemap_debug(void);
389  extern void Swig_typemap_search_debug_set(void);
390  extern void Swig_typemap_used_debug_set(void);
391  extern void Swig_typemap_register_debug_set(void);
392
393  extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f);
394  extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
395  extern void Swig_typemap_new_scope(void);
396  extern Hash *Swig_typemap_pop_scope(void);
397
398  extern void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f);
399
400/* --- Code fragment support --- */
401
402  extern void Swig_fragment_register(Node *fragment);
403  extern void Swig_fragment_emit(String *name);
404  extern void Swig_fragment_clear(String *section);
405
406/* hacks defined in C++ ! */
407  extern int Swig_director_mode(void);
408  extern int Swig_director_protected_mode(void);
409  extern int Swig_all_protected_mode(void);
410  extern void Wrapper_director_mode_set(int);
411  extern void Wrapper_director_protected_mode_set(int);
412  extern void Wrapper_all_protected_mode_set(int);
413  extern void Language_replace_special_variables(String *method, String *tm, Parm *parm);
414  extern void Swig_print(DOH *object, int count);
415  extern void Swig_print_with_location(DOH *object, int count);
416
417
418/* -- template init -- */
419  extern void SwigType_template_init(void);
420
421
422#ifdef __cplusplus
423}
424#endif
425#endif