]>
Commit | Line | Data |
---|---|---|
c90f71dd RD |
1 | /******************************************************************************* |
2 | * Simplified Wrapper and Interface Generator (SWIG) | |
3 | * | |
4 | * Author : David Beazley | |
5 | * | |
6 | * Department of Computer Science | |
7 | * University of Chicago | |
8 | * 1100 E 58th Street | |
9 | * Chicago, IL 60637 | |
10 | * beazley@cs.uchicago.edu | |
11 | * | |
12 | * Please read the file LICENSE for the copyright and terms by which SWIG | |
13 | * can be used and distributed. | |
14 | *******************************************************************************/ | |
15 | /*********************************************************************** | |
16 | * $Header$ | |
17 | * | |
18 | * swig.h | |
19 | * | |
20 | * This is the header file containing the main class definitions and | |
21 | * declarations. Should be included in all extensions and code | |
22 | * modules. | |
23 | * | |
24 | ***********************************************************************/ | |
25 | ||
26 | #ifndef __swig_h_ | |
27 | #define __swig_h_ | |
28 | ||
29 | #include <stdlib.h> | |
30 | #include <stdio.h> | |
31 | #include <string.h> | |
32 | ||
33 | #include "swigver.h" | |
34 | ||
35 | /* Global variables. Needs to be cleaned up */ | |
36 | ||
37 | #ifdef MACSWIG | |
38 | #define Status Swig_Status | |
39 | #undef stderr | |
40 | #define stderr swig_log | |
41 | extern FILE *swig_log; | |
42 | #endif | |
43 | ||
44 | extern FILE *f_header; // Some commonly used | |
45 | extern FILE *f_wrappers; // FILE pointers | |
46 | extern FILE *f_init; | |
47 | extern FILE *f_input; | |
48 | extern char InitName[256]; | |
49 | extern char LibDir[512]; // Library directory | |
50 | extern char **InitNames; // List of other init functions | |
51 | extern int Status; // Variable creation status | |
52 | extern int TypeStrict; // Type checking strictness | |
53 | extern int Verbose; | |
54 | extern int yyparse(); | |
55 | extern int line_number; | |
56 | extern int start_line; | |
57 | extern char *input_file; // Current input file | |
58 | extern int CPlusPlus; // C++ mode | |
59 | extern int ObjC; // Objective-C mode | |
60 | extern int ObjCClass; // Objective-C style class | |
61 | extern int AddMethods; // AddMethods mode | |
62 | extern int NewObject; // NewObject mode | |
63 | extern int Inline; // Inline mode | |
64 | extern int NoInclude; // NoInclude flag | |
65 | extern char *typemap_lang; // Current language name | |
66 | extern int error_count; | |
67 | extern char *copy_string(char *); | |
68 | extern char output_dir[512]; // Output directory | |
69 | ||
70 | #define FatalError() if ((error_count++) > 20) { fprintf(stderr,"Confused by earlier errors. Bailing out\n"); SWIG_exit(1); } | |
71 | ||
72 | /* Miscellaneous stuff */ | |
73 | ||
74 | #define STAT_READONLY 1 | |
75 | #define MAXSCOPE 16 | |
76 | ||
77 | extern char* getSwigLib(); | |
78 | ||
79 | // ----------------------------------------------------------------------- | |
80 | // String class | |
81 | // ----------------------------------------------------------------------- | |
82 | ||
83 | class String { | |
84 | private: | |
85 | int maxsize; // Max size of current string | |
86 | void add(const char *newstr); // Function to add a new string | |
87 | void add(char c); // Add a character | |
88 | void insert(const char *newstr); | |
89 | int len; | |
90 | public: | |
91 | String(); | |
92 | String(const char *s); | |
93 | ~String(); | |
94 | char *get() const; | |
95 | char *str; // String data | |
96 | friend String& operator<<(String&,const char *s); | |
97 | friend String& operator<<(String&,const int); | |
98 | friend String& operator<<(String&,const char); | |
99 | friend String& operator<<(String&,String&); | |
100 | friend String& operator>>(const char *s, String&); | |
101 | friend String& operator>>(String&,String&); | |
102 | String& operator=(const char *); | |
103 | operator char*() const { return str; } | |
104 | void untabify(); | |
105 | void replace(const char *token, const char *rep); | |
106 | void replaceid(const char *id, const char *rep); | |
107 | void strip(); | |
108 | }; | |
109 | ||
110 | #define tab2 " " | |
111 | #define tab4 " " | |
112 | #define tab8 " " | |
113 | #define br "\n" | |
114 | #define endl "\n" | |
115 | #define quote "\"" | |
116 | ||
117 | // ------------------------------------------------------------------- | |
118 | // Hash table class | |
119 | // ------------------------------------------------------------------- | |
120 | ||
121 | class Hash { | |
122 | private: | |
123 | struct Node { | |
124 | Node(const char *k, void *obj, void (*d)(void *)) { | |
125 | key = new char[strlen(k)+1]; | |
126 | strcpy(key,k); | |
127 | object = obj; | |
128 | del_proc = d; | |
129 | next = 0; | |
130 | }; | |
131 | ~Node() { | |
132 | delete key; | |
133 | if (del_proc) (*del_proc)(object); | |
134 | }; | |
135 | char *key; | |
136 | void *object; | |
137 | struct Node *next; | |
138 | void (*del_proc)(void *); | |
139 | }; | |
140 | int h1(const char *key); // Hashing function | |
141 | int hashsize; // Size of hash table | |
142 | Node **hashtable; // Actual hash table | |
143 | int index; // Current index (used by iterators) | |
144 | Node *current; // Current item in hash table | |
145 | public: | |
146 | Hash(); | |
147 | ~Hash(); | |
148 | int add(const char *key, void *object); | |
149 | int add(const char *key, void *object, void (*del)(void *)); | |
150 | void *lookup(const char *key); | |
151 | void remove(const char *key); | |
152 | void *first(); | |
153 | void *next(); | |
154 | char *firstkey(); | |
155 | char *nextkey(); | |
156 | }; | |
157 | ||
158 | /************************************************************************ | |
159 | * class DataType | |
160 | * | |
161 | * Defines the basic datatypes supported by the translator. | |
162 | * | |
163 | ************************************************************************/ | |
164 | ||
165 | #define T_INT 1 | |
166 | #define T_SHORT 2 | |
167 | #define T_LONG 3 | |
168 | #define T_UINT 4 | |
169 | #define T_USHORT 5 | |
170 | #define T_ULONG 6 | |
171 | #define T_UCHAR 7 | |
172 | #define T_SCHAR 8 | |
173 | #define T_BOOL 9 | |
174 | #define T_DOUBLE 10 | |
175 | #define T_FLOAT 11 | |
176 | #define T_CHAR 12 | |
177 | #define T_USER 13 | |
178 | #define T_VOID 14 | |
179 | #define T_SYMBOL 98 | |
180 | #define T_ERROR 99 | |
181 | ||
182 | // These types are now obsolete, but defined for backwards compatibility | |
183 | ||
184 | #define T_SINT 90 | |
185 | #define T_SSHORT 91 | |
186 | #define T_SLONG 92 | |
187 | ||
188 | // Class for storing data types | |
189 | ||
190 | #define MAX_NAME 96 | |
191 | ||
192 | class DataType { | |
193 | private: | |
194 | static Hash *typedef_hash[MAXSCOPE]; | |
195 | static int scope; | |
196 | public: | |
197 | int type; // SWIG Type code | |
198 | char name[MAX_NAME]; // Name of type | |
199 | char is_pointer; // Is this a pointer? | |
200 | char implicit_ptr; // Implicit ptr | |
201 | char is_reference; // A C++ reference type | |
202 | char status; // Is this datatype read-only? | |
203 | char *qualifier; // A qualifier string (ie. const). | |
204 | char *arraystr; // String containing array part | |
205 | int id; // type identifier (unique for every type). | |
206 | DataType(); | |
207 | DataType(DataType *); | |
208 | DataType(int type); | |
209 | ~DataType(); | |
210 | void primitive(); // Turn a datatype into its primitive type | |
211 | char *print_type(); // Return string containing datatype | |
212 | char *print_full(); // Return string with full datatype | |
213 | char *print_cast(); // Return string for type casting | |
214 | char *print_mangle();// Return mangled version of type | |
215 | char *print_real(char *local=0); // Print the real datatype (as far as we can determine) | |
216 | char *print_arraycast(); // Prints an array cast | |
217 | char *print_mangle_default(); // Default mangling scheme | |
218 | ||
219 | // Array query functions | |
220 | int array_dimensions(); // Return number of array dimensions (if any) | |
221 | char *get_dimension(int); // Return string containing a particular dimension | |
222 | char *get_array(); // Returns the array string for a datatype | |
223 | ||
224 | // typedef support | |
225 | ||
226 | void typedef_add(char *name, int mode = 0); // Add this type to typedef list | |
227 | void typedef_resolve(int level = 0); // See if this type has been typedef'd | |
228 | void typedef_replace(); // Replace this type with it's original type | |
229 | static int is_typedef(char *name); // See if this is a typedef | |
230 | void typedef_updatestatus(int newstatus); // Change status of a typedef | |
231 | static void init_typedef(void); // Initialize typedef manager | |
232 | static void merge_scope(Hash *h); // Functions for managing scoping of datatypes | |
233 | static void new_scope(Hash *h = 0); | |
234 | static Hash *collapse_scope(char *); | |
235 | int check_defined(); // Check to see if type is defined by a typedef. | |
236 | }; | |
237 | ||
238 | #define STAT_REPLACETYPE 2 | |
239 | ||
240 | /************************************************************************ | |
241 | * class Parm | |
242 | * | |
243 | * Structure for holding information about function parameters | |
244 | * | |
245 | * CALL_VALUE --> Call by value even though function parameter | |
246 | * is a pointer. | |
247 | * ex : foo(&_arg0); | |
248 | * CALL_REF --> Call by reference even though function parameter | |
249 | * is by value | |
250 | * ex : foo(*_arg0); | |
251 | * | |
252 | ************************************************************************/ | |
253 | ||
254 | #define CALL_VALUE 0x01 | |
255 | #define CALL_REFERENCE 0x02 | |
256 | #define CALL_OUTPUT 0x04 | |
257 | ||
258 | struct Parm { | |
259 | DataType *t; // Datatype of this parameter | |
260 | int call_type; // Call type (value or reference or value) | |
261 | char *name; // Name of parameter (optional) | |
262 | char *defvalue; // Default value (as a string) | |
263 | int ignore; // Ignore flag | |
264 | char *objc_separator; // Parameter separator for Objective-C | |
265 | Parm(DataType *type, char *n); | |
266 | Parm(Parm *p); | |
267 | ~Parm(); | |
268 | }; | |
269 | ||
270 | // ------------------------------------------------------------- | |
271 | // class ParmList | |
272 | // | |
273 | // This class is used for manipulating parameter lists in | |
274 | // function and type declarations. | |
275 | // ------------------------------------------------------------- | |
276 | ||
277 | #define MAXPARMS 16 | |
278 | ||
279 | class ParmList { | |
280 | private: | |
281 | int maxparms; // Max parms possible in current list | |
282 | Parm **parms; // Pointer to parms array | |
283 | void moreparms(); // Increase number of stored parms | |
284 | int current_parm; // Internal state for get_first,get_next | |
285 | public: | |
286 | int nparms; // Number of parms in list | |
287 | void append(Parm *p); // Append a parameter to the end | |
288 | void insert(Parm *p, int pos); // Insert a parameter into the list | |
289 | void del(int pos); // Delete a parameter at position pos | |
290 | int numopt(); // Get number of optional arguments | |
291 | int numarg(); // Get number of active arguments | |
292 | Parm *get(int pos); // Get the parameter at position pos | |
293 | Parm &operator[](int); // An alias for get(). | |
294 | ParmList(); | |
295 | ParmList(ParmList *l); | |
296 | ~ParmList(); | |
297 | ||
298 | // Keep this for backwards compatibility | |
299 | ||
300 | Parm *get_first(); // Get first parameter from list | |
301 | Parm *get_next(); // Get next parameter from list | |
302 | void print_types(FILE *f); // Print list of datatypes | |
303 | void print_types(String &f); // Generate list of datatypes. | |
304 | void print_args(FILE *f); // Print argument list | |
305 | int check_defined(); // Checks to make sure the arguments are defined | |
306 | void sub_parmnames(String &s); // Remaps real parameter names in code fragment | |
307 | }; | |
308 | ||
309 | // Modes for different types of inheritance | |
310 | ||
311 | #define INHERIT_FUNC 0x1 | |
312 | #define INHERIT_VAR 0x2 | |
313 | #define INHERIT_CONST 0x4 | |
314 | #define INHERIT_ALL (INHERIT_FUNC | INHERIT_VAR | INHERIT_CONST) | |
315 | ||
316 | struct Pragma { | |
317 | Pragma() { next = 0; } | |
318 | String filename; | |
319 | int lineno; | |
320 | String lang; | |
321 | String name; | |
322 | String value; | |
323 | Pragma *next; | |
324 | }; | |
325 | ||
326 | /************************************************************************ | |
327 | * class language: | |
328 | * | |
329 | * This class defines the functions that need to be supported by the | |
330 | * scripting language being used. The translator calls these virtual | |
331 | * functions to output different types of code for different languages. | |
332 | * | |
333 | * By implementing this using virtual functions, hopefully it will be | |
334 | * easy to support different types of scripting languages. | |
335 | * | |
336 | * The following functions are used : | |
337 | * | |
338 | * parse_args(argc, argv) | |
339 | * Parse the arguments used by this language. | |
340 | * | |
341 | * parse() | |
342 | * Entry function that starts parsing of a particular language | |
343 | * | |
344 | * create_function(fname, iname, rtype, parmlist) | |
345 | * Creates a function wrappper. | |
346 | * | |
347 | * link_variable(vname, iname, type) | |
348 | * Creates a link to a variable. | |
349 | * | |
350 | * declare_const(cname, type, value) | |
351 | * Creates a constant (for #define). | |
352 | * | |
353 | * initialize(char *fn) | |
354 | * Produces initialization code. | |
355 | * | |
356 | * headers() | |
357 | * Produce code for headers | |
358 | * | |
359 | * close() | |
360 | * Close up files | |
361 | * | |
362 | * usage_var(iname,type,string) | |
363 | * Produces usage string for variable declaration. | |
364 | * | |
365 | * usage_func(iname,rttype, parmlist, string) | |
366 | * Produces usage string for function declaration. | |
367 | * | |
368 | * usage_const(iname, type, value, string) | |
369 | * Produces usage string for constants | |
370 | * | |
371 | * set_module(char *modname) | |
372 | * Sets the name of the module (%module directive) | |
373 | * | |
374 | * set_init(char *initname) | |
375 | * Sets name of initialization function (an alternative to set_module) | |
376 | * add_native(char *name, char *funcname); | |
377 | * Adds a native wrapper function to the initialize process | |
378 | * | |
379 | * type_mangle(DataType *t); | |
380 | * Mangles the name of a datatype. | |
381 | * --- C++ Functions --- | |
382 | * | |
383 | * These functions are optional additions to any of the target | |
384 | * languages. SWIG handles inheritance, symbol tables, and other | |
385 | * information. | |
386 | * | |
387 | * cpp_open_class(char *classname, char *rname) | |
388 | * Open a new C++ class definition. | |
389 | * cpp_close_class(char *) | |
390 | * Close current C++ class | |
391 | * cpp_member_func(char *name, char *rname, DataType *rt, ParmList *l) | |
392 | * Create a C++ member function | |
393 | * cpp_constructor(char *name, char *iname, ParmList *l) | |
394 | * Create a C++ constructor. | |
395 | * cpp_destructor(char *name, char *iname) | |
396 | * Create a C++ destructor | |
397 | * cpp_variable(char *name, char *iname, DataType *t) | |
398 | * Create a C++ member data item. | |
399 | * cpp_declare_const(char *name, char *iname, int type, char *value) | |
400 | * Create a C++ constant. | |
401 | * cpp_inherit(char *baseclass) | |
402 | * Inherit data from baseclass. | |
403 | * cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) | |
404 | * A C++ static member function. | |
405 | * cpp_static_var(char *name, char *iname, DataType *t) | |
406 | * A C++ static member data variable. | |
407 | * | |
408 | *************************************************************************/ | |
409 | ||
410 | class Language { | |
411 | public: | |
412 | virtual void parse_args(int argc, char *argv[]) = 0; | |
413 | virtual void parse() = 0; | |
414 | virtual void create_function(char *, char *, DataType *, ParmList *) = 0; | |
415 | virtual void link_variable(char *, char *, DataType *) = 0; | |
416 | virtual void declare_const(char *, char *, DataType *, char *) = 0; | |
417 | virtual void initialize(void) = 0; | |
418 | virtual void headers(void) = 0; | |
419 | virtual void close(void) = 0; | |
420 | virtual void set_module(char *mod_name,char **mod_list) = 0; | |
421 | virtual void set_init(char *init_name); | |
422 | virtual void add_native(char *, char *); | |
423 | virtual char *type_mangle(DataType *t) { | |
424 | return t->print_mangle_default(); | |
425 | } | |
426 | virtual void add_typedef(DataType *t, char *name); | |
427 | virtual void create_command(char *cname, char *iname); | |
428 | ||
429 | // | |
430 | // C++ language extensions. | |
431 | // You can redefine these, or use the defaults below | |
432 | // | |
433 | ||
434 | virtual void cpp_member_func(char *name, char *iname, DataType *t, ParmList *l); | |
435 | virtual void cpp_constructor(char *name, char *iname, ParmList *l); | |
436 | virtual void cpp_destructor(char *name, char *newname); | |
437 | virtual void cpp_open_class(char *name, char *rename, char *ctype, int strip); | |
438 | virtual void cpp_close_class(); | |
439 | virtual void cpp_cleanup(); | |
440 | virtual void cpp_inherit(char **baseclass, int mode = INHERIT_ALL); | |
441 | virtual void cpp_variable(char *name, char *iname, DataType *t); | |
442 | virtual void cpp_static_func(char *name, char *iname, DataType *t, ParmList *l); | |
443 | virtual void cpp_declare_const(char *name, char *iname, DataType *type, char *value); | |
444 | virtual void cpp_static_var(char *name, char *iname, DataType *t); | |
445 | virtual void cpp_pragma(Pragma *plist); | |
446 | ||
447 | // Pragma directive | |
448 | ||
449 | virtual void pragma(char *, char *, char *); | |
450 | ||
451 | // Declaration of a class, but not a full definition | |
452 | ||
453 | virtual void cpp_class_decl(char *, char *, char *); | |
454 | ||
455 | // Import directive | |
456 | ||
457 | virtual void import(char *filename); | |
458 | ||
459 | }; | |
460 | ||
461 | class Documentation; | |
462 | ||
463 | // -------------------------------------------------------------------- | |
464 | // class DocEntry | |
465 | // | |
466 | // Base class for the documentation system. Basically everything is | |
467 | // a documentation entry of some sort. Specific derived classes | |
468 | // are created internally and shouldn't be accessed by third-party | |
469 | // modules. | |
470 | // -------------------------------------------------------------------- | |
471 | ||
472 | class DocEntry { | |
473 | public: | |
474 | char *name; // Name of the entry | |
475 | String usage; // Short description (optional) | |
476 | String cinfo; // Information about C interface (optional). | |
477 | String text; // Supporting text (optional) | |
478 | DocEntry *parent; // Parent of this entry (optional) | |
479 | DocEntry *child; // Children of this entry (optional) | |
480 | DocEntry *next; // Next entry (or sibling) | |
481 | DocEntry *previous; // Previous entry | |
482 | int counter; // Counter for section control | |
483 | int is_separator; // Is this a separator entry? | |
484 | int sorted; // Sorted? | |
485 | int line_number; // Line number | |
486 | int end_line; // Ending line number | |
487 | int format; // Format this documentation entry | |
488 | int print_info; // Print C information about this entry | |
489 | char *file; // File | |
490 | virtual ~DocEntry(); // Destructor (common to all subclasses) | |
491 | ||
492 | // Methods applicable to all documentation entries | |
493 | ||
494 | virtual void output(Documentation *d); | |
495 | void add(DocEntry *de); // Add documentation entry to the list | |
496 | void addchild(DocEntry *de); // Add documentation entry as a child | |
497 | void sort_children(); // Sort all of the children | |
498 | void remove(); // Remove this doc entry | |
499 | void parse_args(int argc, char **argv); // Parse command line options | |
500 | void style(char *name,char *value);// Change doc style. | |
501 | static DocEntry *dead_entries; // Dead documentation entries | |
502 | }; | |
503 | ||
504 | extern DocEntry *doc_entry; | |
505 | ||
506 | // Default DocEntry style parameters | |
507 | ||
508 | #define SWIGDEFAULT_SORT 0 | |
509 | #define SWIGDEFAULT_FORMAT 1 | |
510 | #define SWIGDEFAULT_INFO 1 | |
511 | ||
512 | // ---------------------------------------------------------------------- | |
513 | // Documentation module base class | |
514 | // | |
515 | // This class defines methods that need to be implemented for a | |
516 | // documentation module. | |
517 | // | |
518 | // title() - Print out a title entry | |
519 | // newsection() - Start a new section (may be nested to form subsections) | |
520 | // endsection() - End a section | |
521 | // print_decl() - Print a standard declaration | |
522 | // print_text() - Print standard text | |
523 | // init() - Initialize the documentation module | |
524 | // close() - Close documentation module | |
525 | // ---------------------------------------------------------------------- | |
526 | ||
527 | class Documentation { | |
528 | public: | |
529 | virtual void parse_args(int argc, char **argv) = 0; | |
530 | virtual void title(DocEntry *de) = 0; | |
531 | virtual void newsection(DocEntry *de, int sectnum) = 0; | |
532 | virtual void endsection() = 0; | |
533 | virtual void print_decl(DocEntry *de) = 0; | |
534 | virtual void print_text(DocEntry *de) = 0; | |
535 | virtual void separator() = 0; | |
536 | virtual void init(char *filename) = 0; | |
537 | virtual void close(void) = 0; | |
538 | virtual void style(char *name, char *value) = 0; | |
539 | }; | |
540 | ||
541 | /* Emit functions */ | |
542 | ||
543 | extern void emit_extern_var(char *, DataType *, int, FILE *); | |
544 | extern void emit_extern_func(char *, DataType *, ParmList *, int, FILE *); | |
545 | extern int emit_args(DataType *, ParmList *, FILE *); | |
546 | ||
547 | extern void emit_func_call(char *, DataType *, ParmList *, FILE *); | |
548 | ||
549 | extern void emit_hex(FILE *); | |
550 | extern void emit_set_get(char *, char *, DataType *); | |
551 | extern void emit_banner(FILE *); | |
552 | extern void emit_ptr_equivalence(FILE *); | |
553 | extern int SWIG_main(int, char **, Language *, Documentation *); | |
554 | extern void make_wrap_name(char *); | |
555 | ||
556 | // Some functions for emitting some C++ helper code | |
557 | ||
558 | extern void cplus_emit_member_func(char *classname, char *classtype, char *classrename, | |
559 | char *mname, char *mrename, DataType *type, ParmList *l, | |
560 | int mode); | |
561 | ||
562 | extern void cplus_emit_static_func(char *classname, char *classtype, char *classrename, | |
563 | char *mname, char *mrename, DataType *type, ParmList *l, | |
564 | int mode); | |
565 | ||
566 | extern void cplus_emit_destructor(char *classname, char *classtype, char *classrename, | |
567 | char *name, char *iname, int mode); | |
568 | ||
569 | extern void cplus_emit_constructor(char *classname, char *classtype, char *classrename, | |
570 | char *name, char *iname, ParmList *l, int mode); | |
571 | ||
572 | extern void cplus_emit_variable_get(char *classname, char *classtype, char *classrename, | |
573 | char *name, char *iname, DataType *type, int mode); | |
574 | ||
575 | extern void cplus_emit_variable_set(char *classname, char *classtype, char *classrename, | |
576 | char *name, char *iname, DataType *type, int mode); | |
577 | ||
578 | extern char *cplus_base_class(char *name); | |
579 | ||
580 | extern void cplus_support_doc(String &f); | |
581 | ||
582 | /* Function for building search directories */ | |
583 | ||
584 | extern void add_directory(char *dirname); | |
585 | extern int insert_file(char *, FILE *); | |
586 | extern int get_file(char *filename, String &str); | |
587 | extern int checkout_file(char *filename, char *dest); | |
588 | extern int checkin_file(char *dir, char *lang, char *source, char *dest); | |
589 | extern int include_file(char *filename); | |
590 | ||
591 | /* Miscellaneous */ | |
592 | ||
593 | extern void check_options(); | |
594 | extern void init_args(int argc, char **); | |
595 | extern void mark_arg(int n); | |
596 | extern void arg_error(); | |
597 | ||
598 | extern void library_add(char *name); | |
599 | extern void library_insert(); | |
600 | ||
601 | // ----------------------------------------------------------------------- | |
602 | // Class for Creating Wrapper Functions | |
603 | // ----------------------------------------------------------------------- | |
604 | ||
605 | class WrapperFunction { | |
606 | private: | |
607 | Hash h; | |
608 | public: | |
609 | String def; | |
610 | String locals; | |
611 | String code; | |
612 | String init; | |
613 | void print(FILE *f); | |
614 | void print(String &f); | |
615 | void add_local(char *type, char *name, char *defvalue = 0); | |
616 | char *new_local(char *type, char *name, char *defvalue = 0); | |
617 | static void del_type(void *obj); | |
618 | }; | |
619 | ||
620 | extern int emit_args(DataType *, ParmList *, WrapperFunction &f); | |
621 | extern void emit_func_call(char *, DataType *, ParmList *, WrapperFunction &f); | |
622 | extern void SWIG_exit(int); | |
623 | ||
624 | // Symbol table management | |
625 | ||
626 | extern int add_symbol(char *, DataType *, char *); | |
627 | extern void remove_symbol(char *); | |
628 | extern int update_symbol(char *, DataType *, char *); | |
629 | extern char *lookup_symvalue(char *); | |
630 | extern DataType *lookup_symtype(char *); | |
631 | extern int lookup_symbol(char *); | |
632 | ||
633 | // ----------------------------------------------------------------------- | |
634 | // Typemap support | |
635 | // ----------------------------------------------------------------------- | |
636 | ||
637 | extern void typemap_register(char *op, char *lang, DataType *type, char *pname, char *code, ParmList *l = 0); | |
638 | extern void typemap_register(char *op, char *lang, char *type, char *pname, char *code,ParmList *l = 0); | |
639 | extern void typemap_register_default(char *op, char *lang, int type, int ptr, char *arraystr, char *code, ParmList *l = 0); | |
640 | extern char *typemap_lookup(char *op, char *lang, DataType *type, char *pname, char *source, char *target, | |
641 | WrapperFunction *f = 0); | |
642 | extern void typemap_clear(char *op, char *lang, DataType *type, char *pname); | |
643 | extern void typemap_copy(char *op, char *lang, DataType *stype, char *sname, DataType *ttype, char *tname); | |
644 | extern char *typemap_check(char *op, char *lang, DataType *type, char *pname); | |
645 | extern void typemap_apply(DataType *tm_type, char *tmname, DataType *type, char *pname); | |
646 | extern void typemap_clear_apply(DataType *type, char *pname); | |
647 | ||
648 | ||
649 | // ----------------------------------------------------------------------- | |
650 | // Code fragment support | |
651 | // ----------------------------------------------------------------------- | |
652 | ||
653 | extern void fragment_register(char *op, char *lang, char *code); | |
654 | extern char *fragment_lookup(char *op, char *lang, int age); | |
655 | extern void fragment_clear(char *op, char *lang); | |
656 | ||
657 | ||
658 | extern void emit_ptr_equivalence(WrapperFunction &); | |
659 | ||
660 | // ----------------------------------------------------------------------- | |
661 | // Naming system | |
662 | // ----------------------------------------------------------------------- | |
663 | ||
664 | #define AS_IS 1 | |
665 | ||
666 | extern void name_register(char *method, char *format); | |
667 | extern int name_scope(int); | |
668 | extern char *name_wrapper(char *fname, char *prefix, int suppress=0); | |
669 | extern char *name_member(char *fname, char *classname, int suppress=0); | |
670 | extern char *name_get(char *vname, int suppress=0); | |
671 | extern char *name_set(char *vname, int suppress=0); | |
672 | extern char *name_construct(char *classname, int suppress=0); | |
673 | extern char *name_destroy(char *classname, int suppress=0); | |
674 | ||
675 | ||
676 | #endif |