beautify/format source code with gnu indent

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9505 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2006-11-01 23:54:54 +00:00
commit aa04c4c057
72 changed files with 27038 additions and 28016 deletions

File diff suppressed because it is too large Load diff

View file

@ -38,8 +38,8 @@ char cvsroot_error_c[] = "$Header$";
# define DEFAULT_ERROR_MSG_FORMAT EMF_STANDARD
#endif
static ErrorMessageFormat msg_format = DEFAULT_ERROR_MSG_FORMAT;
static int silence = 0; /* Silent operation */
static String *filter = 0; /* Warning filter */
static int silence = 0; /* Silent operation */
static String *filter = 0; /* Warning filter */
static int warnall = 0;
static int nwarning = 0;
static int nerrors = 0;
@ -58,22 +58,23 @@ static String *format_filename(const String_or_char *filename);
* Issue a warning message
* ----------------------------------------------------------------------------- */
void
Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt, ...) {
void Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt, ...) {
String *out;
char *msg;
int wrn = 1;
char *msg;
int wrn = 1;
va_list ap;
if (silence) return;
if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
if (silence)
return;
if (!init_fmt)
Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
va_start(ap,fmt);
va_start(ap, fmt);
out = NewStringEmpty();
vPrintf(out,fmt,ap);
vPrintf(out, fmt, ap);
msg = Char(out);
if (isdigit((unsigned char)*msg)) {
if (isdigit((unsigned char) *msg)) {
unsigned long result = strtoul(msg, &msg, 10);
if (msg != Char(out)) {
msg++;
@ -83,13 +84,15 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
/* Check in the warning filter */
if (filter) {
char temp[32];
char temp[32];
char *c;
char *f = Char(filter);
sprintf(temp,"%d",wnum);
while(*f != '\0' && (c = strstr(f,temp))) {
if (*(c-1) == '-') wrn = 0; /* Warning disabled */
if (*(c-1) == '+') wrn = 1; /* Warning enabled */
sprintf(temp, "%d", wnum);
while (*f != '\0' && (c = strstr(f, temp))) {
if (*(c - 1) == '-')
wrn = 0; /* Warning disabled */
if (*(c - 1) == '+')
wrn = 1; /* Warning enabled */
f += strlen(temp);
}
}
@ -100,7 +103,7 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
} else {
Printf(stderr, wrn_nnum_fmt, formatted_filename, line);
}
Printf(stderr,"%s",msg);
Printf(stderr, "%s", msg);
nwarning++;
Delete(formatted_filename);
}
@ -114,22 +117,23 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
* Issue an error message
* ----------------------------------------------------------------------------- */
void
Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
void Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
va_list ap;
String *formatted_filename = NULL;
if (silence) return;
if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
va_start(ap,fmt);
if (silence)
return;
if (!init_fmt)
Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
va_start(ap, fmt);
formatted_filename = format_filename(filename);
if (line > 0) {
Printf(stderr, err_line_fmt, formatted_filename, line);
} else {
Printf(stderr, err_eof_fmt, formatted_filename);
}
vPrintf(stderr,fmt,ap);
vPrintf(stderr, fmt, ap);
va_end(ap);
nerrors++;
Delete(formatted_filename);
@ -141,8 +145,7 @@ Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
* Returns number of errors received.
* ----------------------------------------------------------------------------- */
int
Swig_error_count(void) {
int Swig_error_count(void) {
return nerrors;
}
@ -152,8 +155,7 @@ Swig_error_count(void) {
* Set silent flag
* ----------------------------------------------------------------------------- */
void
Swig_error_silent(int s) {
void Swig_error_silent(int s) {
silence = s;
}
@ -164,14 +166,14 @@ Swig_error_silent(int s) {
* Takes a comma separate list of warning numbers and puts in the filter.
* ----------------------------------------------------------------------------- */
void
Swig_warnfilter(const String_or_char *wlist, int add) {
void Swig_warnfilter(const String_or_char *wlist, int add) {
char *c;
char *cw;
String *s;
if (!filter) filter = NewStringEmpty();
if (!filter)
filter = NewStringEmpty();
s = NewString("");
Clear(s);
cw = Char(wlist);
@ -182,31 +184,30 @@ Swig_warnfilter(const String_or_char *wlist, int add) {
++cw;
}
c = Char(s);
c = strtok(c,", ");
c = strtok(c, ", ");
while (c) {
if (isdigit((int) *c) || (*c == '+') || (*c == '-')) {
if (add) {
Insert(filter,0,c);
Insert(filter, 0, c);
if (isdigit((int) *c)) {
Insert(filter,0,"-");
Insert(filter, 0, "-");
}
} else {
char temp[32];
if (isdigit((int) *c)) {
sprintf(temp,"-%s",c);
sprintf(temp, "-%s", c);
} else {
strcpy(temp,c);
strcpy(temp, c);
}
Replace(filter,temp,"", DOH_REPLACE_FIRST);
Replace(filter, temp, "", DOH_REPLACE_FIRST);
}
}
c = strtok(NULL,", ");
c = strtok(NULL, ", ");
}
Delete(s);
}
void
Swig_warnall(void) {
void Swig_warnall(void) {
warnall = 1;
}
@ -217,8 +218,7 @@ Swig_warnall(void) {
* Return the number of warnings
* ----------------------------------------------------------------------------- */
int
Swig_warn_count(void) {
int Swig_warn_count(void) {
return nwarning;
}
@ -228,31 +228,30 @@ Swig_warn_count(void) {
* Set the type of error/warning message display
* ----------------------------------------------------------------------------- */
void
Swig_error_msg_format(ErrorMessageFormat format) {
const char* error = "Error";
const char* warning = "Warning";
void Swig_error_msg_format(ErrorMessageFormat format) {
const char *error = "Error";
const char *warning = "Warning";
const char* fmt_eof = 0;
const char* fmt_line = 0;
const char *fmt_eof = 0;
const char *fmt_line = 0;
/* here 'format' could be directly a string instead of an enum, but
by now a switch is used to translated into one. */
switch (format) {
case EMF_MICROSOFT:
fmt_line = "%s(%d)";
fmt_eof = "%s(999999)"; /* Is there a special character for EOF? Just use a large number. */
fmt_eof = "%s(999999)"; /* Is there a special character for EOF? Just use a large number. */
break;
case EMF_STANDARD:
default:
fmt_line = "%s:%d";
fmt_eof = "%s:EOF";
fmt_eof = "%s:EOF";
}
sprintf(wrn_wnum_fmt, "%s: %s(%%d): ", fmt_line, warning);
sprintf(wrn_nnum_fmt, "%s: %s: ", fmt_line, warning);
sprintf(err_line_fmt, "%s: %s: ", fmt_line, error);
sprintf(err_eof_fmt, "%s: %s: ", fmt_eof, error);
sprintf(wrn_nnum_fmt, "%s: %s: ", fmt_line, warning);
sprintf(err_line_fmt, "%s: %s: ", fmt_line, error);
sprintf(err_eof_fmt, "%s: %s: ", fmt_eof, error);
msg_format = format;
init_fmt = 1;
@ -263,12 +262,10 @@ Swig_error_msg_format(ErrorMessageFormat format) {
*
* Remove double backslashes in Windows filename paths for display
* ----------------------------------------------------------------------------- */
static String *
format_filename(const String_or_char *filename) {
static String *format_filename(const String_or_char *filename) {
String *formatted_filename = NewString(filename);
#if defined(_WIN32)
Replaceall(formatted_filename,"\\\\","\\");
Replaceall(formatted_filename, "\\\\", "\\");
#endif
return formatted_filename;
return formatted_filename;
}

View file

@ -30,35 +30,36 @@ static int debug = 0;
* changed, lang.cxx doesn't nedd to be touched again.
* ----------------------------------------------------------------------------- */
void
Swig_fragment_register(Node* fragment) {
if (Getattr(fragment,k_emitonly)) {
void Swig_fragment_register(Node *fragment) {
if (Getattr(fragment, k_emitonly)) {
Swig_fragment_emit(fragment);
return;
} else {
String *name = Copy(Getattr(fragment,k_value));
String *type = Getattr(fragment,k_type);
String *name = Copy(Getattr(fragment, k_value));
String *type = Getattr(fragment, k_type);
if (type) {
SwigType *rtype = SwigType_typedef_resolve_all(type);
String *mangle = Swig_string_mangle(type);
Append(name,mangle);
Append(name, mangle);
Delete(mangle);
Delete(rtype);
if (debug) Printf(stdout,"register fragment %s %s\n",name,type);
if (debug)
Printf(stdout, "register fragment %s %s\n", name, type);
}
if (!fragments) {
fragments = NewHash();
}
if (!Getattr(fragments,name)) {
String *section = Copy(Getattr(fragment,k_section));
String *ccode = Copy(Getattr(fragment,k_code));
Hash *kwargs = Getattr(fragment,k_kwargs);
Setmeta(ccode,k_section,section);
if (!Getattr(fragments, name)) {
String *section = Copy(Getattr(fragment, k_section));
String *ccode = Copy(Getattr(fragment, k_code));
Hash *kwargs = Getattr(fragment, k_kwargs);
Setmeta(ccode, k_section, section);
if (kwargs) {
Setmeta(ccode,k_kwargs,kwargs);
Setmeta(ccode, k_kwargs, kwargs);
}
Setattr(fragments,name,ccode);
if (debug) Printf(stdout,"registering fragment %s %s\n",name,section);
Setattr(fragments, name, ccode);
if (debug)
Printf(stdout, "registering fragment %s %s\n", name, section);
Delete(section);
Delete(ccode);
}
@ -73,16 +74,15 @@ Swig_fragment_register(Node* fragment) {
* ----------------------------------------------------------------------------- */
static
char* char_index(char* str, char c)
{
while (*str && (c != *str)) ++str;
char *char_index(char *str, char c) {
while (*str && (c != *str))
++str;
return (c == *str) ? str : 0;
}
void
Swig_fragment_emit(Node *n) {
void Swig_fragment_emit(Node *n) {
String *code;
char *pc, *tok;
char *pc, *tok;
String *t;
String *mangle = 0;
String *name = 0;
@ -92,38 +92,44 @@ Swig_fragment_emit(Node *n) {
Swig_warning(WARN_FRAGMENT_NOT_FOUND, Getfile(n), Getline(n), "Fragment '%s' not found.\n", name);
return;
}
name = Getattr(n,k_value);
name = Getattr(n, k_value);
if (!name) {
name = n;
}
type = Getattr(n,k_type);
type = Getattr(n, k_type);
if (type) {
mangle = Swig_string_mangle(type);
}
if (debug) Printf(stdout,"looking fragment %s %s\n",name, type);
if (debug)
Printf(stdout, "looking fragment %s %s\n", name, type);
t = Copy(name);
tok = Char(t);
pc = char_index(tok,',');
if (pc) *pc = 0;
pc = char_index(tok, ',');
if (pc)
*pc = 0;
while (tok) {
String *name = NewString(tok);
if (mangle) Append(name,mangle);
if (looking_fragments && Getattr(looking_fragments,name)) {
if (mangle)
Append(name, mangle);
if (looking_fragments && Getattr(looking_fragments, name)) {
return;
}
code = Getattr(fragments,name);
if (debug) Printf(stdout,"looking subfragment %s\n", name);
if (code && (Strcmp(code,k_ignore) != 0)) {
String *section = Getmeta(code,k_section);
Hash *nn = Getmeta(code,k_kwargs);
if (!looking_fragments) looking_fragments = NewHash();
Setattr(looking_fragments,name,"1");
}
code = Getattr(fragments, name);
if (debug)
Printf(stdout, "looking subfragment %s\n", name);
if (code && (Strcmp(code, k_ignore) != 0)) {
String *section = Getmeta(code, k_section);
Hash *nn = Getmeta(code, k_kwargs);
if (!looking_fragments)
looking_fragments = NewHash();
Setattr(looking_fragments, name, "1");
while (nn) {
if (Equal(Getattr(nn,k_name),k_fragment)) {
if (debug) Printf(stdout,"emitting fragment %s %s\n",nn, type);
if (Equal(Getattr(nn, k_name), k_fragment)) {
if (debug)
Printf(stdout, "emitting fragment %s %s\n", nn, type);
Setfile(nn, Getfile(n));
Setline(nn, Getline(n));
Swig_fragment_emit(nn);
@ -133,23 +139,25 @@ Swig_fragment_emit(Node *n) {
if (section) {
File *f = Swig_filebyname(section);
if (!f) {
Swig_error(Getfile(code),Getline(code),
"Bad section '%s' for code fragment '%s'\n", section,name);
Swig_error(Getfile(code), Getline(code), "Bad section '%s' for code fragment '%s'\n", section, name);
} else {
if (debug) Printf(stdout,"emitting subfragment %s %s\n",name, section);
if (debug) Printf(f,"/* begin fragment %s */\n",name);
Printf(f,"%s\n",code);
if (debug) Printf(f,"/* end fragment %s */\n\n",name);
Setattr(fragments,name,k_ignore);
Delattr(looking_fragments,name);
if (debug)
Printf(stdout, "emitting subfragment %s %s\n", name, section);
if (debug)
Printf(f, "/* begin fragment %s */\n", name);
Printf(f, "%s\n", code);
if (debug)
Printf(f, "/* end fragment %s */\n\n", name);
Setattr(fragments, name, k_ignore);
Delattr(looking_fragments, name);
}
}
} else if (!code && type) {
SwigType *rtype = SwigType_typedef_resolve_all(type);
if (!Equal(type,rtype)) {
String *name = Copy(Getattr(n,k_value));
if (!Equal(type, rtype)) {
String *name = Copy(Getattr(n, k_value));
String *mangle = Swig_string_mangle(type);
Append(name,mangle);
Append(name, mangle);
Setfile(name, Getfile(n));
Setline(name, Getline(n));
Swig_fragment_emit(name);
@ -158,17 +166,17 @@ Swig_fragment_emit(Node *n) {
}
Delete(rtype);
}
if (!code) {
Swig_warning(WARN_FRAGMENT_NOT_FOUND, Getfile(n), Getline(n), "Fragment '%s' not found.\n", name);
}
tok = pc ? pc + 1 : 0;
if (tok) {
pc = char_index(tok,',');
if (pc) *pc = 0;
pc = char_index(tok, ',');
if (pc)
*pc = 0;
}
Delete(name);
}
Delete(t);
}

View file

@ -21,8 +21,8 @@ char cvsroot_getopt_c[] = "$Header$";
#include "swig.h"
static char **args;
static int numargs;
static int *marked;
static int numargs;
static int *marked;
/* -----------------------------------------------------------------------------
* Swig_init_args()
@ -30,8 +30,7 @@ static int *marked;
* Initialize the argument list handler.
* ----------------------------------------------------------------------------- */
void
Swig_init_args(int argc, char **argv) {
void Swig_init_args(int argc, char **argv) {
int i;
assert(argc > 0);
assert(argv);
@ -51,11 +50,10 @@ Swig_init_args(int argc, char **argv) {
* Marks an argument as being parsed.
* ----------------------------------------------------------------------------- */
void
Swig_mark_arg(int n) {
assert(marked);
assert((n >= 0) && (n < numargs));
marked[n] = 1;
void Swig_mark_arg(int n) {
assert(marked);
assert((n >= 0) && (n < numargs));
marked[n] = 1;
}
/* -----------------------------------------------------------------------------
@ -64,9 +62,8 @@ Swig_mark_arg(int n) {
* Checks to see if argument has been picked up.
* ----------------------------------------------------------------------------- */
int
Swig_check_marked(int n) {
assert((n>=0) && (n < numargs));
int Swig_check_marked(int n) {
assert((n >= 0) && (n < numargs));
return marked[n];
}
@ -75,27 +72,26 @@ Swig_check_marked(int n) {
*
* Checkers for unprocessed command line options and errors.
* ----------------------------------------------------------------------------- */
void
Swig_check_options(int check_input) {
int error = 0;
int i;
int max = check_input ? numargs - 1 : numargs;
assert(marked);
for (i = 1; i < max; i++) {
if (!marked[i]) {
Printf(stderr,"swig error : Unrecognized option %s\n", args[i]);
error=1;
}
}
if (error) {
Printf(stderr,"Use 'swig -help' for available options.\n");
exit(1);
}
if (check_input && marked[numargs-1]) {
Printf(stderr,"Must specify an input file. Use -help for available options.\n");
exit(1);
void Swig_check_options(int check_input) {
int error = 0;
int i;
int max = check_input ? numargs - 1 : numargs;
assert(marked);
for (i = 1; i < max; i++) {
if (!marked[i]) {
Printf(stderr, "swig error : Unrecognized option %s\n", args[i]);
error = 1;
}
}
if (error) {
Printf(stderr, "Use 'swig -help' for available options.\n");
exit(1);
}
if (check_input && marked[numargs - 1]) {
Printf(stderr, "Must specify an input file. Use -help for available options.\n");
exit(1);
}
}
/* -----------------------------------------------------------------------------
@ -104,13 +100,8 @@ Swig_check_options(int check_input) {
* Generates a generic error message and exits.
* ----------------------------------------------------------------------------- */
void
Swig_arg_error() {
Printf(stderr,"SWIG : Unable to parse command line options.\n");
Printf(stderr,"Use 'swig -help' for available options.\n");
void Swig_arg_error() {
Printf(stderr, "SWIG : Unable to parse command line options.\n");
Printf(stderr, "Use 'swig -help' for available options.\n");
exit(1);
}

View file

@ -16,11 +16,11 @@ char cvsroot_include_c[] = "$Header$";
/* Delimeter used in accessing files and directories */
static List *directories = 0; /* List of include directories */
static String *lastpath = 0; /* Last file that was included */
static String *swiglib = 0; /* Location of SWIG library */
static String *lang_config = 0; /* Language configuration file */
static int dopush = 1; /* Whether to push directories */
static List *directories = 0; /* List of include directories */
static String *lastpath = 0; /* Last file that was included */
static String *swiglib = 0; /* Location of SWIG library */
static String *lang_config = 0; /* Language configuration file */
static int dopush = 1; /* Whether to push directories */
/* This functions determine whether to push/pop dirs in the preprocessor */
void Swig_set_push_dir(int push) {
@ -51,13 +51,11 @@ String *Swig_get_config_file() {
* include mechanism, but rather as a query interface for language modules.
* ----------------------------------------------------------------------------- */
void
Swig_swiglib_set(const String_or_char *sl) {
void Swig_swiglib_set(const String_or_char *sl) {
swiglib = NewString(sl);
}
String *
Swig_swiglib_get() {
String *Swig_swiglib_get() {
return swiglib;
}
@ -67,9 +65,9 @@ Swig_swiglib_get() {
* Adds a directory to the SWIG search path.
* ----------------------------------------------------------------------------- */
List *
Swig_add_directory(const String_or_char *dirname) {
if (!directories) directories = NewList();
List *Swig_add_directory(const String_or_char *dirname) {
if (!directories)
directories = NewList();
assert(directories);
if (dirname) {
String *sdir = NewString(dirname);
@ -93,21 +91,23 @@ Swig_add_directory(const String_or_char *dirname) {
* the preprocessor to grab files in the same directory as other included files.
* ----------------------------------------------------------------------------- */
void
Swig_push_directory(const String_or_char *dirname) {
void Swig_push_directory(const String_or_char *dirname) {
String *tmp = 0;
if (!Swig_get_push_dir()) return;
if (!directories) directories = NewList();
if (!Swig_get_push_dir())
return;
if (!directories)
directories = NewList();
assert(directories);
if (!DohIsString(dirname)) {
dirname = tmp = NewString(dirname);
assert(dirname);
}
}
if (dirname) {
Hash *dir = NewHash();
Setattr(dir, k_name, dirname);
Insert(directories, 0, dir);
if (tmp) Delete(tmp);
if (tmp)
Delete(tmp);
}
}
@ -118,11 +118,12 @@ Swig_push_directory(const String_or_char *dirname) {
* the preprocessor.
* ----------------------------------------------------------------------------- */
void
Swig_pop_directory() {
if (!Swig_get_push_dir()) return;
if (!directories) return;
Delitem(directories,0);
void Swig_pop_directory() {
if (!Swig_get_push_dir())
return;
if (!directories)
return;
Delitem(directories, 0);
}
/* -----------------------------------------------------------------------------
@ -131,8 +132,7 @@ Swig_pop_directory() {
* Returns the full pathname of the last file opened.
* ----------------------------------------------------------------------------- */
String *
Swig_last_file() {
String *Swig_last_file() {
assert(lastpath);
return lastpath;
}
@ -143,11 +143,10 @@ Swig_last_file() {
* Returns a list of the current search paths.
* ----------------------------------------------------------------------------- */
static List *
Swig_search_path_any(int syspath) {
static List *Swig_search_path_any(int syspath) {
String *filename;
String *dirname;
List *slist, *llist;
List *slist, *llist;
int i, ilen;
llist = 0;
@ -156,35 +155,35 @@ Swig_search_path_any(int syspath) {
filename = NewStringEmpty();
assert(filename);
#ifdef MACSWIG
Printf(filename,"%s",SWIG_FILE_DELIMETER);
Printf(filename, "%s", SWIG_FILE_DELIMETER);
#else
Printf(filename,".%s", SWIG_FILE_DELIMETER);
Printf(filename, ".%s", SWIG_FILE_DELIMETER);
#endif
if (syspath) {
llist = NewList();
assert(llist);
Append(llist,filename);
Append(llist, filename);
} else {
Append(slist,filename);
}
Append(slist, filename);
}
ilen = Len(directories);
for (i = 0; i < ilen; i++) {
int issimple = 0;
dirname = Getitem(directories,i);
dirname = Getitem(directories, i);
filename = NewStringEmpty();
assert(filename);
if (DohIsString(dirname)) {
filename = Copy(dirname);
issimple = 1;
} else {
filename = Copy(Getattr(dirname,k_name));
filename = Copy(Getattr(dirname, k_name));
}
StringAppend(filename, SWIG_FILE_DELIMETER);
if (syspath && (issimple || !GetFlag(dirname,k_sysdir))) {
Append(llist,filename);
if (syspath && (issimple || !GetFlag(dirname, k_sysdir))) {
Append(llist, filename);
} else {
Append(slist,filename);
Append(slist, filename);
/* Insert(slist,0,filename); */
}
Delete(filename);
@ -192,16 +191,15 @@ Swig_search_path_any(int syspath) {
if (syspath) {
int ilen = Len(llist);
for (i = 0; i < ilen; i++) {
Append(slist,Getitem(llist,i));
Append(slist, Getitem(llist, i));
}
Delete(llist);
}
return slist;
}
}
List *
Swig_search_path() {
List *Swig_search_path() {
return Swig_search_path_any(0);
}
@ -213,36 +211,37 @@ Swig_search_path() {
* Looks for a file and open it. Returns an open FILE * on success.
* ----------------------------------------------------------------------------- */
static FILE *
Swig_open_any(const String_or_char *name, int sysfile) {
FILE *f;
String *filename;
List *spath = 0;
char *cname;
int i, ilen;
static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
FILE *f;
String *filename;
List *spath = 0;
char *cname;
int i, ilen;
if (!directories) directories = NewList();
if (!directories)
directories = NewList();
assert(directories);
cname = Char(name);
filename = NewString(cname);
assert(filename);
f = fopen(Char(filename),"r");
f = fopen(Char(filename), "r");
if (!f) {
spath = Swig_search_path_any(sysfile);
ilen = Len(spath);
for (i = 0; i < ilen; i++) {
Clear(filename);
Printf(filename,"%s%s", Getitem(spath,i), cname);
f = fopen(Char(filename),"r");
if (f) break;
}
Delete(spath);
spath = Swig_search_path_any(sysfile);
ilen = Len(spath);
for (i = 0; i < ilen; i++) {
Clear(filename);
Printf(filename, "%s%s", Getitem(spath, i), cname);
f = fopen(Char(filename), "r");
if (f)
break;
}
Delete(spath);
}
if (f) {
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
Replaceall(filename,"\\\\","\\"); /* remove double '\' in case any already present */
Replaceall(filename,"\\","\\\\");
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
Replaceall(filename, "\\\\", "\\"); /* remove double '\' in case any already present */
Replaceall(filename, "\\", "\\\\");
#endif
Delete(lastpath);
lastpath = Copy(filename);
@ -251,8 +250,7 @@ Swig_open_any(const String_or_char *name, int sysfile) {
return f;
}
FILE *
Swig_open(const String_or_char *name) {
FILE *Swig_open(const String_or_char *name) {
return Swig_open_any(name, 0);
}
@ -264,24 +262,23 @@ Swig_open(const String_or_char *name) {
* Reads data from an open FILE * and returns it as a string.
* ----------------------------------------------------------------------------- */
String *
Swig_read_file(FILE *f) {
int len;
char buffer[4096];
String *Swig_read_file(FILE *f) {
int len;
char buffer[4096];
String *str = NewStringEmpty();
assert(str);
while (fgets(buffer,4095,f)) {
StringAppend(str,buffer);
while (fgets(buffer, 4095, f)) {
StringAppend(str, buffer);
}
len = StringLen(str);
if (len) {
char *cstr = Char(str);
if (cstr[len - 1] != '\n') {
StringAppend(str, "\n");
}
}
}
return str;
}
@ -291,31 +288,29 @@ Swig_read_file(FILE *f) {
* Opens a file and returns it as a string.
* ----------------------------------------------------------------------------- */
static String *
Swig_include_any(const String_or_char *name, int sysfile) {
FILE *f;
String *str;
String *file;
static String *Swig_include_any(const String_or_char *name, int sysfile) {
FILE *f;
String *str;
String *file;
f = Swig_open_any(name, sysfile);
if (!f) return 0;
if (!f)
return 0;
str = Swig_read_file(f);
fclose(f);
Seek(str,0,SEEK_SET);
Seek(str, 0, SEEK_SET);
file = Copy(lastpath);
Setfile(str,file);
Setfile(str, file);
Delete(file);
Setline(str,1);
Setline(str, 1);
return str;
}
String *
Swig_include(const String_or_char *name) {
String *Swig_include(const String_or_char *name) {
return Swig_include_any(name, 0);
}
String *
Swig_include_sys(const String_or_char *name) {
String *Swig_include_sys(const String_or_char *name) {
return Swig_include_any(name, 1);
}
@ -326,15 +321,15 @@ Swig_include_sys(const String_or_char *name) {
* Copies the contents of a file into another file
* ----------------------------------------------------------------------------- */
int
Swig_insert_file(const String_or_char *filename, File *outfile) {
int Swig_insert_file(const String_or_char *filename, File *outfile) {
char buffer[4096];
int nbytes;
int nbytes;
FILE *f = Swig_open(filename);
if (!f) return -1;
while ((nbytes = Read(f,buffer,4096)) > 0) {
Write(outfile,buffer,nbytes);
if (!f)
return -1;
while ((nbytes = Read(f, buffer, 4096)) > 0) {
Write(outfile, buffer, nbytes);
}
return 0;
}
@ -350,9 +345,9 @@ Swig_insert_file(const String_or_char *filename, File *outfile) {
static Hash *named_files = 0;
void
Swig_register_filebyname(const String_or_char *filename, File *outfile) {
if (!named_files) named_files = NewHash();
void Swig_register_filebyname(const String_or_char *filename, File *outfile) {
if (!named_files)
named_files = NewHash();
Setattr(named_files, filename, outfile);
}
@ -362,10 +357,10 @@ Swig_register_filebyname(const String_or_char *filename, File *outfile) {
* Get a named file
* ----------------------------------------------------------------------------- */
File *
Swig_filebyname(const String_or_char *filename) {
if (!named_files) return 0;
return Getattr(named_files,filename);
File *Swig_filebyname(const String_or_char *filename) {
if (!named_files)
return 0;
return Getattr(named_files, filename);
}
/* -----------------------------------------------------------------------------
@ -374,18 +369,18 @@ Swig_filebyname(const String_or_char *filename) {
* Returns the suffix of a file
* ----------------------------------------------------------------------------- */
char *
Swig_file_suffix(const String_or_char *filename) {
char *Swig_file_suffix(const String_or_char *filename) {
char *d;
char *c = Char(filename);
int len = Len(filename);
if (strlen(c)) {
d = c + len - 1;
while (d != c) {
if (*d == '.') return d;
if (*d == '.')
return d;
d--;
}
return c+len;
return c + len;
}
return c;
}
@ -396,12 +391,10 @@ Swig_file_suffix(const String_or_char *filename) {
* Returns the filename with no suffix attached.
* ----------------------------------------------------------------------------- */
char *
Swig_file_basename(const String_or_char *filename)
{
char *Swig_file_basename(const String_or_char *filename) {
static char tmp[1024];
char *c;
strcpy(tmp,Char(filename));
strcpy(tmp, Char(filename));
c = Swig_file_suffix(tmp);
*c = 0;
return tmp;
@ -412,16 +405,16 @@ Swig_file_basename(const String_or_char *filename)
*
* Return the file with any leading path stripped off
* ----------------------------------------------------------------------------- */
char *
Swig_file_filename(const String_or_char *filename)
{
char *Swig_file_filename(const String_or_char *filename) {
static char tmp[1024];
const char *delim = SWIG_FILE_DELIMETER;
char *c;
strcpy(tmp,Char(filename));
if ((c=strrchr(tmp,*delim))) return c+1;
else return tmp;
strcpy(tmp, Char(filename));
if ((c = strrchr(tmp, *delim)))
return c + 1;
else
return tmp;
}
/* -----------------------------------------------------------------------------
@ -429,22 +422,17 @@ Swig_file_filename(const String_or_char *filename)
*
* Return the name of the directory associated with a file
* ----------------------------------------------------------------------------- */
char *
Swig_file_dirname(const String_or_char *filename)
{
char *Swig_file_dirname(const String_or_char *filename) {
static char tmp[1024];
const char *delim = SWIG_FILE_DELIMETER;
char *c;
strcpy(tmp,Char(filename));
if (!strstr(tmp,delim)) {
strcpy(tmp, Char(filename));
if (!strstr(tmp, delim)) {
return "";
}
c = tmp + strlen(tmp) -1;
while (*c != *delim) c--;
c = tmp + strlen(tmp) - 1;
while (*c != *delim)
c--;
*(++c) = 0;
return tmp;
}

View file

@ -22,12 +22,11 @@ char cvsroot_misc_c[] = "$Header$";
* Duplicate a NULL-terminate string given as a char *.
* ----------------------------------------------------------------------------- */
char *
Swig_copy_string(const char *s) {
char *Swig_copy_string(const char *s) {
char *c = 0;
if (s) {
c = (char *) malloc(strlen(s)+1);
strcpy(c,s);
c = (char *) malloc(strlen(s) + 1);
strcpy(c, s);
}
return c;
}
@ -38,10 +37,8 @@ Swig_copy_string(const char *s) {
* Emits the SWIG identifying banner.
* ----------------------------------------------------------------------------- */
void
Swig_banner(File *f) {
Printf(f,
"/* ----------------------------------------------------------------------------\n\
void Swig_banner(File *f) {
Printf(f, "/* ----------------------------------------------------------------------------\n\
* This file was automatically generated by SWIG (http://www.swig.org).\n\
* Version %s\n\
* \n\
@ -50,8 +47,7 @@ Swig_banner(File *f) {
* changes to this file unless you know what you are doing--modify the SWIG \n\
* interface file instead. \n", PACKAGE_VERSION);
/* String too long for ISO compliance */
Printf(f,
" * ----------------------------------------------------------------------------- */\n\n");
Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
}
@ -65,27 +61,28 @@ String *Swig_string_escape(String *s) {
String *ns;
int c;
ns = NewStringEmpty();
while ((c = Getc(s)) != EOF) {
if (c == '\n') {
Printf(ns,"\\n");
Printf(ns, "\\n");
} else if (c == '\r') {
Printf(ns,"\\r");
Printf(ns, "\\r");
} else if (c == '\t') {
Printf(ns,"\\t");
Printf(ns, "\\t");
} else if (c == '\\') {
Printf(ns,"\\\\");
Printf(ns, "\\\\");
} else if (c == '\'') {
Printf(ns,"\\'");
Printf(ns, "\\'");
} else if (c == '\"') {
Printf(ns,"\\\"");
Printf(ns, "\\\"");
} else if (c == ' ') {
Putc(c,ns);
Putc(c, ns);
} else if (!isgraph(c)) {
if (c < 0) c += UCHAR_MAX +1;
Printf(ns,"\\%o", c);
if (c < 0)
c += UCHAR_MAX + 1;
Printf(ns, "\\%o", c);
} else {
Putc(c,ns);
Putc(c, ns);
}
}
return ns;
@ -103,9 +100,9 @@ String *Swig_string_upper(String *s) {
int c;
ns = NewStringEmpty();
Seek(s,0,SEEK_SET);
Seek(s, 0, SEEK_SET);
while ((c = Getc(s)) != EOF) {
Putc(toupper(c),ns);
Putc(toupper(c), ns);
}
return ns;
}
@ -121,9 +118,9 @@ String *Swig_string_lower(String *s) {
int c;
ns = NewStringEmpty();
Seek(s,0,SEEK_SET);
Seek(s, 0, SEEK_SET);
while ((c = Getc(s)) != EOF) {
Putc(tolower(c),ns);
Putc(tolower(c), ns);
}
return ns;
}
@ -142,9 +139,9 @@ String *Swig_string_title(String *s) {
int c;
ns = NewStringEmpty();
Seek(s,0,SEEK_SET);
Seek(s, 0, SEEK_SET);
while ((c = Getc(s)) != EOF) {
Putc(first ? toupper(c) : tolower(c),ns);
Putc(first ? toupper(c) : tolower(c), ns);
first = 0;
}
return ns;
@ -166,9 +163,9 @@ String *Swig_string_ccase(String *s) {
int c;
ns = NewStringEmpty();
Seek(s,0,SEEK_SET);
Seek(s, 0, SEEK_SET);
while ((c = Getc(s)) != EOF) {
if (c == '_') {
if (c == '_') {
first = 1;
continue;
}
@ -196,7 +193,7 @@ String *Swig_string_lccase(String *s) {
int c;
ns = NewStringEmpty();
Seek(s,0,SEEK_SET);
Seek(s, 0, SEEK_SET);
while ((c = Getc(s)) != EOF) {
if (c == '_') {
after_underscore = 1;
@ -212,6 +209,7 @@ String *Swig_string_lccase(String *s) {
}
return ns;
}
/* -----------------------------------------------------------------------------
* Swig_string_ucase()
*
@ -224,31 +222,31 @@ String *Swig_string_ucase(String *s) {
String *ns;
int c;
int lastC = 0;
int underscore = 0;
int underscore = 0;
ns = NewStringEmpty();
/* We insert a underscore when:
1. Lower case char followed by upper case char
getFoo > get_foo; getFOo > get_foo; GETFOO > getfoo
2. Number proceded by char
get2D > get_2d; get22D > get_22d; GET2D > get_2d */
1. Lower case char followed by upper case char
getFoo > get_foo; getFOo > get_foo; GETFOO > getfoo
2. Number proceded by char
get2D > get_2d; get22D > get_22d; GET2D > get_2d */
Seek(s,0,SEEK_SET);
Seek(s, 0, SEEK_SET);
while ((c = Getc(s)) != EOF) {
if (isdigit(c) && isalpha(lastC))
underscore = 1;
else if (isupper(c) && isalpha(lastC) && !isupper(lastC))
underscore = 1;
lastC = c;
if (underscore) {
Putc('_',ns);
Putc('_', ns);
underscore = 0;
}
}
Putc(tolower(c),ns);
Putc(tolower(c), ns);
}
return ns;
}
@ -268,7 +266,7 @@ String *Swig_string_first_upper(String *s) {
String *ns = NewStringEmpty();
char *cs = Char(s);
if (cs && cs[0] != 0) {
Putc(toupper(cs[0]),ns);
Putc(toupper(cs[0]), ns);
Append(ns, cs + 1);
}
return ns;
@ -289,7 +287,7 @@ String *Swig_string_first_lower(String *s) {
String *ns = NewStringEmpty();
char *cs = Char(s);
if (cs && cs[0] != 0) {
Putc(tolower(cs[0]),ns);
Putc(tolower(cs[0]), ns);
Append(ns, cs + 1);
}
return ns;
@ -327,30 +325,33 @@ String *Swig_string_typecode(String *s) {
String *str = 0;
tc = NewStringEmpty();
while ((c = Getc(s)) != EOF) {
if (c == '`') break;
Putc(c,tc);
if (c == '`')
break;
Putc(c, tc);
}
str = SwigType_str(tc,0);
Append(ns,str);
str = SwigType_str(tc, 0);
Append(ns, str);
Delete(str);
} else {
Putc(c,ns);
Putc(c, ns);
if (c == '\'') {
while ((c = Getc(s)) != EOF) {
Putc(c,ns);
if (c == '\'') break;
Putc(c, ns);
if (c == '\'')
break;
if (c == '\\') {
c = Getc(s);
Putc(c,ns);
Putc(c, ns);
}
}
} else if (c == '\"') {
while ((c = Getc(s)) != EOF) {
Putc(c,ns);
if (c == '\"') break;
Putc(c, ns);
if (c == '\"')
break;
if (c == '\\') {
c = Getc(s);
Putc(c,ns);
Putc(c, ns);
}
}
}
@ -358,7 +359,7 @@ String *Swig_string_typecode(String *s) {
}
return ns;
}
/* -----------------------------------------------------------------------------
* Swig_string_mangle()
*
@ -382,12 +383,13 @@ String *Swig_string_typecode(String *s) {
* ----------------------------------------------------------------------------- */
String *Swig_string_mangle(const String *s) {
#if 0
#if 0
/* old mangling, not suitable for using in macros */
String *t = Copy(s);
char *c = Char(t);
while (*c) {
if (!isalnum(*c)) *c = '_';
if (!isalnum(*c))
*c = '_';
c++;
}
return t;
@ -399,26 +401,26 @@ String *Swig_string_mangle(const String *s) {
String *b = Copy(s);
if (SwigType_istemplate(b)) {
String *st = Swig_symbol_template_deftype(b, 0);
String *sq = Swig_symbol_type_qualify(st,0);
String *sq = Swig_symbol_type_qualify(st, 0);
String *t = SwigType_namestr(sq);
Delete(st);
Delete(sq);
Delete(b);
b = t ;
b = t;
}
pc = cb = StringChar(b);
while (*pc) {
char c = *pc;
if (isalnum((int)c) || (c == '_')) {
if (isalnum((int) c) || (c == '_')) {
state = 1;
if (space && (space == state)) {
StringAppend(result,"_SS_");
StringAppend(result, "_SS_");
}
space = 0;
Printf(result,"%c",(int)c);
Printf(result, "%c", (int) c);
} else {
if (isspace((int)c)) {
if (isspace((int) c)) {
space = state;
++pc;
continue;
@ -426,10 +428,10 @@ String *Swig_string_mangle(const String *s) {
state = 3;
space = 0;
}
switch(c) {
switch (c) {
case '.':
if ((cb != pc) && (*(pc - 1) == 'p')) {
StringAppend(result,"_");
StringAppend(result, "_");
++pc;
continue;
} else {
@ -438,8 +440,9 @@ String *Swig_string_mangle(const String *s) {
break;
case ':':
if (*(pc + 1) == ':') {
StringAppend(result,"_");
++pc; ++pc;
StringAppend(result, "_");
++pc;
++pc;
continue;
}
break;
@ -503,10 +506,10 @@ String *Swig_string_mangle(const String *s) {
default:
break;
}
if (isalpha((int)c)) {
Printf(result,"_S%c_",(int)c);
} else{
Printf(result,"_S%02X_",(int)c);
if (isalpha((int) c)) {
Printf(result, "_S%c_", (int) c);
} else {
Printf(result, "_S%02X_", (int) c);
}
}
++pc;
@ -528,18 +531,17 @@ String *Swig_string_emangle(String *s) {
* In this case, "A::B". Returns NULL if there is no base.
* ----------------------------------------------------------------------------- */
void
Swig_scopename_split(String *s, String **rprefix, String **rlast) {
void Swig_scopename_split(String *s, String **rprefix, String **rlast) {
char *tmp = Char(s);
char *c = tmp;
char *cc = c;
char *co = 0;
if (!strstr(c,"::")) {
if (!strstr(c, "::")) {
*rprefix = 0;
*rlast = Copy(s);
}
if ((co = strstr(cc,"operator "))) {
if ((co = strstr(cc, "operator "))) {
if (co == cc) {
*rprefix = 0;
*rlast = Copy(s);
@ -551,7 +553,7 @@ Swig_scopename_split(String *s, String **rprefix, String **rlast) {
}
}
while (*c) {
if ((*c == ':') && (*(c+1) == ':')) {
if ((*c == ':') && (*(c + 1) == ':')) {
cc = c;
c += 2;
} else {
@ -559,8 +561,10 @@ Swig_scopename_split(String *s, String **rprefix, String **rlast) {
int level = 1;
c++;
while (*c && level) {
if (*c == '<') level++;
if (*c == '>') level--;
if (*c == '<')
level++;
if (*c == '>')
level--;
c++;
}
} else {
@ -580,14 +584,14 @@ Swig_scopename_split(String *s, String **rprefix, String **rlast) {
}
String *
Swig_scopename_prefix(String *s) {
String *Swig_scopename_prefix(String *s) {
char *tmp = Char(s);
char *c = tmp;
char *cc = c;
char *co = 0;
if (!strstr(c,"::")) return 0;
if ((co = strstr(cc,"operator "))) {
if (!strstr(c, "::"))
return 0;
if ((co = strstr(cc, "operator "))) {
if (co == cc) {
return 0;
} else {
@ -596,7 +600,7 @@ Swig_scopename_prefix(String *s) {
}
}
while (*c) {
if ((*c == ':') && (*(c+1) == ':')) {
if ((*c == ':') && (*(c + 1) == ':')) {
cc = c;
c += 2;
} else {
@ -604,8 +608,10 @@ Swig_scopename_prefix(String *s) {
int level = 1;
c++;
while (*c && level) {
if (*c == '<') level++;
if (*c == '>') level--;
if (*c == '<')
level++;
if (*c == '>')
level--;
c++;
}
} else {
@ -628,21 +634,21 @@ Swig_scopename_prefix(String *s) {
* case, "C".
* ----------------------------------------------------------------------------- */
String *
Swig_scopename_last(String *s) {
String *Swig_scopename_last(String *s) {
char *tmp = Char(s);
char *c = tmp;
char *cc = c;
char *co = 0;
if (!strstr(c,"::")) return NewString(s);
if (!strstr(c, "::"))
return NewString(s);
if ((co = strstr(cc,"operator "))) {
if ((co = strstr(cc, "operator "))) {
return NewString(co);
}
while (*c) {
if ((*c == ':') && (*(c+1) == ':')) {
if ((*c == ':') && (*(c + 1) == ':')) {
cc = c;
c += 2;
} else {
@ -650,8 +656,10 @@ Swig_scopename_last(String *s) {
int level = 1;
c++;
while (*c && level) {
if (*c == '<') level++;
if (*c == '>') level--;
if (*c == '<')
level++;
if (*c == '>')
level--;
c++;
}
} else {
@ -659,7 +667,7 @@ Swig_scopename_last(String *s) {
}
}
}
return NewString(cc+2);
return NewString(cc + 2);
}
/* -----------------------------------------------------------------------------
@ -669,30 +677,32 @@ Swig_scopename_last(String *s) {
* In this case, "A". Returns NULL if there is no base.
* ----------------------------------------------------------------------------- */
String *
Swig_scopename_first(String *s) {
String *Swig_scopename_first(String *s) {
char *tmp = Char(s);
char *c = tmp;
char *c = tmp;
char *co = 0;
if (!strstr(c,"::")) return 0;
if ((co = strstr(c,"operator "))) {
if (!strstr(c, "::"))
return 0;
if ((co = strstr(c, "operator "))) {
if (co == c) {
return 0;
}
} else {
co = c + Len(s);
}
while (*c && (c != co)) {
if ((*c == ':') && (*(c+1) == ':')) {
if ((*c == ':') && (*(c + 1) == ':')) {
break;
} else {
if (*c == '<') {
int level = 1;
c++;
while (*c && level) {
if (*c == '<') level++;
if (*c == '>') level--;
if (*c == '<')
level++;
if (*c == '>')
level--;
c++;
}
} else {
@ -715,25 +725,28 @@ Swig_scopename_first(String *s) {
* In this case, "B::C". Returns NULL if there is no suffix.
* ----------------------------------------------------------------------------- */
String *
Swig_scopename_suffix(String *s) {
String *Swig_scopename_suffix(String *s) {
char *tmp = Char(s);
char *c = tmp;
char *co = 0;
if (!strstr(c,"::")) return 0;
if ((co = strstr(c,"operator "))) {
if (co == c) return 0;
if (!strstr(c, "::"))
return 0;
if ((co = strstr(c, "operator "))) {
if (co == c)
return 0;
}
while (*c) {
if ((*c == ':') && (*(c+1) == ':')) {
if ((*c == ':') && (*(c + 1) == ':')) {
break;
} else {
if (*c == '<') {
int level = 1;
c++;
while (*c && level) {
if (*c == '<') level++;
if (*c == '>') level--;
if (*c == '<')
level++;
if (*c == '>')
level--;
c++;
}
} else {
@ -742,11 +755,12 @@ Swig_scopename_suffix(String *s) {
}
}
if (*c && (c != tmp)) {
return NewString(c+2);
return NewString(c + 2);
} else {
return 0;
}
}
/* -----------------------------------------------------------------------------
* Swig_scopename_check()
*
@ -756,20 +770,24 @@ Swig_scopename_suffix(String *s) {
int Swig_scopename_check(String *s) {
char *c = Char(s);
char *co = 0;
if ((co = strstr(c,"operator "))) {
if (co == c) return 0;
if ((co = strstr(c, "operator "))) {
if (co == c)
return 0;
}
if (!strstr(c,"::")) return 0;
if (!strstr(c, "::"))
return 0;
while (*c) {
if ((*c == ':') && (*(c+1) == ':')) {
if ((*c == ':') && (*(c + 1) == ':')) {
return 1;
} else {
if (*c == '<') {
int level = 1;
c++;
while (*c && level) {
if (*c == '<') level++;
if (*c == '>') level--;
if (*c == '<')
level++;
if (*c == '>')
level--;
c++;
}
} else {
@ -809,15 +827,15 @@ String *Swig_string_command(String *s) {
#if defined(HAVE_POPEN)
if (Len(s)) {
char *command = Char(s);
FILE *fp = popen(command,"r");
FILE *fp = popen(command, "r");
if (fp) {
char buffer[1025];
while(fscanf(fp,"%1024s",buffer) != EOF) {
Append(res,buffer);
while (fscanf(fp, "%1024s", buffer) != EOF) {
Append(res, buffer);
}
pclose(fp);
} else {
Swig_error("SWIG",Getline(s), "Command encoder fails attempting '%s'.\n", s);
Swig_error("SWIG", Getline(s), "Command encoder fails attempting '%s'.\n", s);
exit(1);
}
}
@ -839,8 +857,7 @@ String *Swig_string_command(String *s) {
#define USE_RXSPENCER
#endif
const char *skip_delim(char pb, char pe, const char *ce)
{
const char *skip_delim(char pb, char pe, const char *ce) {
int end = 0;
int lb = 0;
while (!end && *ce != '\0') {
@ -872,45 +889,45 @@ String *Swig_string_rxspencer(String *s) {
int retval;
regex_t compiled;
cb = ++cs;
ce = skip_delim('[',']', cb);
ce = skip_delim('[', ']', cb);
if (ce) {
char bregexp[512];
strncpy(bregexp, cb, ce - cb);
bregexp[ce - cb] = '\0';
++ce;
retval = regcomp(&compiled, bregexp, REG_EXTENDED);
if(retval == 0) {
if (retval == 0) {
cs = ce;
if (*cs == '[') {
cb = ++cs;
ce = skip_delim('[',']', cb) ;
ce = skip_delim('[', ']', cb);
if (ce) {
const char *cvalue = ce + 1;
int nsub = (int) compiled.re_nsub+1;
regmatch_t *pmatch = (regmatch_t *)malloc(sizeof(regmatch_t)*(nsub));
retval = regexec(&compiled,cvalue,nsub,pmatch,0);
int nsub = (int) compiled.re_nsub + 1;
regmatch_t *pmatch = (regmatch_t *) malloc(sizeof(regmatch_t) * (nsub));
retval = regexec(&compiled, cvalue, nsub, pmatch, 0);
if (retval != REG_NOMATCH) {
char *spos = 0;
res = NewStringWithSize(cb, ce - cb);
spos = Strchr(res,'@');
spos = Strchr(res, '@');
while (spos) {
char cd = *(++spos);
if (isdigit(cd)) {
char arg[8];
size_t len;
int i = cd - '0';
sprintf(arg,"@%d", i);
sprintf(arg, "@%d", i);
if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) {
char value[256];
strncpy(value,cvalue + pmatch[i].rm_so, len);
strncpy(value, cvalue + pmatch[i].rm_so, len);
value[len] = 0;
Replaceall(res,arg,value);
Replaceall(res, arg, value);
} else {
Replaceall(res,arg,"");
Replaceall(res, arg, "");
}
spos = Strchr(res,'@');
spos = Strchr(res, '@');
} else if (cd == '@') {
spos = strchr(spos + 1,'@');
spos = strchr(spos + 1, '@');
}
}
}
@ -922,12 +939,13 @@ String *Swig_string_rxspencer(String *s) {
}
}
}
if (!res) res = NewStringEmpty();
if (!res)
res = NewStringEmpty();
return res;
}
#else
String *Swig_string_rxspencer(String *s) {
(void)s;
(void) s;
return NewStringEmpty();
}
#endif
@ -939,8 +957,7 @@ String *Swig_string_rxspencer(String *s) {
* Initialize the SWIG core
* ----------------------------------------------------------------------------- */
void
Swig_init() {
void Swig_init() {
/* Set some useful string encoding methods */
DohEncoding("escape", Swig_string_escape);
DohEncoding("upper", Swig_string_upper);
@ -949,7 +966,7 @@ Swig_init() {
DohEncoding("ctitle", Swig_string_ccase);
DohEncoding("lctitle", Swig_string_lccase);
DohEncoding("utitle", Swig_string_ucase);
DohEncoding("typecode",Swig_string_typecode);
DohEncoding("typecode", Swig_string_typecode);
DohEncoding("mangle", Swig_string_emangle);
DohEncoding("command", Swig_string_command);
DohEncoding("rxspencer", Swig_string_rxspencer);

File diff suppressed because it is too large Load diff

View file

@ -20,13 +20,13 @@ char cvsroot_parms_c[] = "$Header$";
Parm *NewParm(SwigType *type, const String_or_char *name) {
Parm *p = NewHash();
Setattr(p,k_nodetype,k_parm);
Setattr(p, k_nodetype, k_parm);
if (type) {
SwigType *ntype = Copy(type);
Setattr(p,k_type,ntype);
Setattr(p, k_type, ntype);
Delete(ntype);
}
Setattr(p,k_name,name);
Setattr(p, k_name, name);
return p;
}
@ -42,7 +42,7 @@ Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
return p;
}
@ -51,45 +51,45 @@ Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) {
* ------------------------------------------------------------------------ */
Parm *CopyParm(Parm *p) {
Parm *np = NewHash();
SwigType *t = HashGetAttr(p,k_type);
String *name = HashGetAttr(p,k_name);
String *lname = HashGetAttr(p,k_lname);
String *value = HashGetAttr(p,k_value);
String *ignore = HashGetAttr(p,k_ignore);
String *alttype = HashGetAttr(p,k_alttype);
String *byname = HashGetAttr(p, k_argbyname);
String *compactdefargs = HashGetAttr(p, k_compactdefargs);
String *self = HashGetAttr(p, k_self);
Parm *np = NewHash();
SwigType *t = HashGetAttr(p, k_type);
String *name = HashGetAttr(p, k_name);
String *lname = HashGetAttr(p, k_lname);
String *value = HashGetAttr(p, k_value);
String *ignore = HashGetAttr(p, k_ignore);
String *alttype = HashGetAttr(p, k_alttype);
String *byname = HashGetAttr(p, k_argbyname);
String *compactdefargs = HashGetAttr(p, k_compactdefargs);
String *self = HashGetAttr(p, k_self);
if (t) {
SwigType *nt = Copy(t);
Setattr(np,k_type,nt);
Setattr(np, k_type, nt);
Delete(nt);
}
if (name) {
String *str = Copy(name);
Setattr(np,k_name,str);
Setattr(np, k_name, str);
Delete(str);
}
if (lname) {
String *str = Copy(lname);
Setattr(np,k_lname, str);
Setattr(np, k_lname, str);
Delete(str);
}
if (value) {
String *str = Copy(value);
Setattr(np,k_value, str);
Setattr(np, k_value, str);
Delete(str);
}
if (ignore) {
String *str = Copy(ignore);
Setattr(np,k_ignore, str);
Setattr(np, k_ignore, str);
Delete(str);
}
if (alttype) {
String *str = Copy(alttype);
Setattr(np,k_alttype, str);
Setattr(np, k_alttype, str);
Delete(str);
}
if (byname) {
@ -98,7 +98,7 @@ Parm *CopyParm(Parm *p) {
Delete(str);
}
if (compactdefargs) {
String *str = Copy(compactdefargs);
String *str = Copy(compactdefargs);
Setattr(np, k_compactdefargs, str);
Delete(str);
}
@ -107,9 +107,9 @@ Parm *CopyParm(Parm *p) {
Setattr(np, k_self, str);
Delete(str);
}
Setfile(np,Getfile(p));
Setline(np,Getline(p));
Setfile(np, Getfile(p));
Setline(np, Getline(p));
return np;
}
@ -118,19 +118,19 @@ Parm *CopyParm(Parm *p) {
* CopyParmList()
* ------------------------------------------------------------------ */
ParmList *
CopyParmList(ParmList *p) {
ParmList *CopyParmList(ParmList *p) {
Parm *np;
Parm *pp = 0;
Parm *fp = 0;
if (!p) return 0;
if (!p)
return 0;
while (p) {
np = CopyParm(p);
if (pp) {
set_nextSibling(pp,np);
Delete(np);
set_nextSibling(pp, np);
Delete(np);
} else {
fp = np;
}
@ -145,9 +145,10 @@ CopyParmList(ParmList *p) {
* ------------------------------------------------------------------ */
int ParmList_numarg(ParmList *p) {
int n = 0;
int n = 0;
while (p) {
if (!HashGetAttr(p,k_ignore)) n++;
if (!HashGetAttr(p, k_ignore))
n++;
p = nextSibling(p);
}
return n;
@ -160,11 +161,14 @@ int ParmList_numarg(ParmList *p) {
int ParmList_numrequired(ParmList *p) {
int i = 0;
while (p) {
SwigType *t = HashGetAttr(p,k_type);
String *value = HashGetAttr(p,k_value);
if (value) return i;
if (!(SwigType_type(t) == T_VOID)) i++;
else break;
SwigType *t = HashGetAttr(p, k_type);
String *value = HashGetAttr(p, k_value);
if (value)
return i;
if (!(SwigType_type(t) == T_VOID))
i++;
else
break;
p = nextSibling(p);
}
return i;
@ -191,12 +195,12 @@ int ParmList_len(ParmList *p) {
String *ParmList_str(ParmList *p) {
String *out = NewStringEmpty();
while(p) {
String *pstr = SwigType_str(HashGetAttr(p,k_type), HashGetAttr(p,k_name));
StringAppend(out,pstr);
while (p) {
String *pstr = SwigType_str(HashGetAttr(p, k_type), HashGetAttr(p, k_name));
StringAppend(out, pstr);
p = nextSibling(p);
if (p) {
StringAppend(out,",");
StringAppend(out, ",");
}
Delete(pstr);
}
@ -211,18 +215,18 @@ String *ParmList_str(ParmList *p) {
String *ParmList_str_defaultargs(ParmList *p) {
String *out = NewStringEmpty();
while(p) {
String *value = HashGetAttr(p,k_value);
String *pstr = SwigType_str(HashGetAttr(p,k_type), HashGetAttr(p,k_name));
StringAppend(out,pstr);
while (p) {
String *value = HashGetAttr(p, k_value);
String *pstr = SwigType_str(HashGetAttr(p, k_type), HashGetAttr(p, k_name));
StringAppend(out, pstr);
if (value) {
Printf(out,"=%s", value);
Printf(out, "=%s", value);
}
p = nextSibling(p);
if (p) {
StringAppend(out,",");
StringAppend(out, ",");
}
Delete(pstr);
Delete(pstr);
}
return out;
}
@ -235,15 +239,15 @@ String *ParmList_str_defaultargs(ParmList *p) {
String *ParmList_protostr(ParmList *p) {
String *out = NewStringEmpty();
while(p) {
if (HashGetAttr(p,k_hidden)) {
while (p) {
if (HashGetAttr(p, k_hidden)) {
p = nextSibling(p);
} else {
String *pstr = SwigType_str(HashGetAttr(p,k_type), 0);
StringAppend(out,pstr);
String *pstr = SwigType_str(HashGetAttr(p, k_type), 0);
StringAppend(out, pstr);
p = nextSibling(p);
if (p) {
StringAppend(out,",");
StringAppend(out, ",");
}
Delete(pstr);
}
@ -260,16 +264,16 @@ String *ParmList_protostr(ParmList *p) {
int ParmList_is_compactdefargs(ParmList *p) {
int compactdefargs = 0;
if (p) {
compactdefargs = HashGetAttr(p,k_compactdefargs) ? 1 : 0;
compactdefargs = HashGetAttr(p, k_compactdefargs) ? 1 : 0;
/* The "compactdefargs" attribute should only be set on the first parameter in the list.
* However, sometimes an extra parameter is inserted at the beginning of the parameter list,
* so we check the 2nd parameter too. */
if (!compactdefargs) {
Parm *nextparm = nextSibling(p);
compactdefargs = (nextparm && HashGetAttr(nextparm,k_compactdefargs)) ? 1 : 0;
compactdefargs = (nextparm && HashGetAttr(nextparm, k_compactdefargs)) ? 1 : 0;
}
}
@ -285,15 +289,15 @@ int ParmList_is_compactdefargs(ParmList *p) {
* ---------------------------------------------------------------------- */
int ParmList_has_defaultargs(ParmList *p) {
int default_args = 0;
while (p) {
if (HashGetAttr(p, k_value)) {
default_args = 1;
break;
}
p = nextSibling(p);
int default_args = 0;
while (p) {
if (HashGetAttr(p, k_value)) {
default_args = 1;
break;
}
return default_args;
p = nextSibling(p);
}
return default_args;
}
/* ---------------------------------------------------------------------
@ -304,14 +308,14 @@ int ParmList_has_defaultargs(ParmList *p) {
* ---------------------------------------------------------------------- */
ParmList *ParmList_copy_all_except_last_parm(ParmList *p) {
ParmList* newparms = 0;
ParmList *newparms = 0;
Parm *newparm = 0;
Parm *pp = 0;
Parm *fp = 0;
while (nextSibling(p)) {
newparm = CopyParm(p);
if (pp) {
set_nextSibling(pp,newparm);
set_nextSibling(pp, newparm);
Delete(newparm);
} else {
fp = newparm;

File diff suppressed because it is too large Load diff

View file

@ -86,7 +86,7 @@ char cvsroot_stype_c[] = "$Header$";
SwigType *NewSwigType(int t) {
switch(t) {
switch (t) {
case T_BOOL:
return NewString("bool");
break;
@ -102,7 +102,7 @@ SwigType *NewSwigType(int t) {
case T_USHORT:
return NewString("unsigned short");
break;
case T_LONG:
case T_LONG:
return NewString("long");
break;
case T_ULONG:
@ -126,12 +126,12 @@ SwigType *NewSwigType(int t) {
case T_UCHAR:
return NewString("unsigned char");
break;
case T_STRING: {
SwigType *t = NewString("char");
SwigType_add_pointer(t);
return t;
break;
}
case T_STRING:{
SwigType *t = NewString("char");
SwigType_add_pointer(t);
return t;
break;
}
case T_LONGLONG:
return NewString("long long");
break;
@ -141,7 +141,7 @@ SwigType *NewSwigType(int t) {
case T_VOID:
return NewString("void");
break;
default :
default:
break;
}
return NewStringEmpty();
@ -153,17 +153,18 @@ SwigType *NewSwigType(int t) {
* Push a type constructor onto the type
* ----------------------------------------------------------------------------- */
void SwigType_push(SwigType *t, String *cons)
{
if (!cons) return;
if (!Len(cons)) return;
void SwigType_push(SwigType *t, String *cons) {
if (!cons)
return;
if (!Len(cons))
return;
if (Len(t)) {
char *c = Char(cons);
if (c[strlen(c)-1] != '.')
Insert(t,0,".");
if (c[strlen(c) - 1] != '.')
Insert(t, 0, ".");
}
Insert(t,0,cons);
Insert(t, 0, cons);
}
/* -----------------------------------------------------------------------------
@ -178,36 +179,39 @@ void SwigType_push(SwigType *t, String *cons)
* ----------------------------------------------------------------------------- */
int SwigType_ispointer_return(SwigType *t) {
char* c;
char *c;
int idx;
if (!t) return 0;
if (!t)
return 0;
c = Char(t);
idx = strlen(c)-4;
idx = strlen(c) - 4;
if (idx >= 0) {
return (strcmp(c+idx, ").p.") == 0);
return (strcmp(c + idx, ").p.") == 0);
}
return 0;
}
int SwigType_isreference_return(SwigType *t) {
char* c;
char *c;
int idx;
if (!t) return 0;
if (!t)
return 0;
c = Char(t);
idx = strlen(c)-4;
idx = strlen(c) - 4;
if (idx >= 0) {
return (strcmp(c+idx, ").r.") == 0);
return (strcmp(c + idx, ").r.") == 0);
}
return 0;
}
int SwigType_isconst(SwigType *t) {
char *c;
if (!t) return 0;
if (!t)
return 0;
c = Char(t);
if (strncmp(c,"q(",2) == 0) {
if (strncmp(c, "q(", 2) == 0) {
String *q = SwigType_parm(t);
if (strstr(Char(q),"const")) {
if (strstr(Char(q), "const")) {
Delete(q);
return 1;
}
@ -239,8 +243,9 @@ int SwigType_ismutable(SwigType *t) {
int SwigType_isenum(SwigType *t) {
char *c = Char(t);
if (!t) return 0;
if (strncmp(c,"enum ",5) == 0) {
if (!t)
return 0;
if (strncmp(c, "enum ", 5) == 0) {
return 1;
}
return 0;
@ -248,19 +253,23 @@ int SwigType_isenum(SwigType *t) {
int SwigType_issimple(SwigType *t) {
char *c = Char(t);
if (!t) return 0;
if (!t)
return 0;
while (*c) {
if (*c == '<') {
int nest = 1;
c++;
while (*c && nest) {
if (*c == '<') nest++;
if (*c == '>') nest--;
if (*c == '<')
nest++;
if (*c == '>')
nest--;
c++;
}
c--;
}
if (*c == '.') return 0;
if (*c == '.')
return 0;
c++;
}
return 1;
@ -319,14 +328,13 @@ static Hash *default_cache = 0;
p.SWIGTYPE -> SWIGTYPE
*/
static
void SwigType_add_default(String *def, SwigType *nr)
{
if (Strcmp(nr,"SWIGTYPE") == 0) {
StringAppend(def,"SWIGTYPE");
static
void SwigType_add_default(String *def, SwigType *nr) {
if (Strcmp(nr, "SWIGTYPE") == 0) {
StringAppend(def, "SWIGTYPE");
} else {
String *q = SwigType_isqualifier(nr) ? SwigType_pop(nr) : 0;
if (q && strstr(Char(nr),"SWIGTYPE")) {
if (q && strstr(Char(nr), "SWIGTYPE")) {
StringAppend(def, nr);
} else {
String *nd = SwigType_default(nr);
@ -334,17 +342,17 @@ void SwigType_add_default(String *def, SwigType *nr)
String *bdef = nd;
if (q) {
bdef = NewStringf("%s%s", q, nd);
if ((Strcmp(nr,bdef) == 0)) {
if ((Strcmp(nr, bdef) == 0)) {
Delete(bdef);
bdef = nd;
} else {
Delete(nd);
}
}
StringAppend(def,bdef);
StringAppend(def, bdef);
Delete(bdef);
} else {
StringAppend(def,nr);
StringAppend(def, nr);
}
}
Delete(q);
@ -358,28 +366,31 @@ SwigType *SwigType_default(SwigType *t) {
char *cr;
#ifdef SWIG_DEFAULT_CACHE
if (!default_cache) default_cache = NewHash();
r = Getattr(default_cache,t);
if (!default_cache)
default_cache = NewHash();
r = Getattr(default_cache, t);
if (r) {
return Copy(r);
}
#endif
if (SwigType_isvarargs(t)) {
return 0;
}
r = t;
while ((r1 = SwigType_typedef_resolve(r))) {
if (r != t) Delete(r);
if (r != t)
Delete(r);
r = r1;
}
if (SwigType_isqualifier(r)) {
String *q;
if (r == t) r = Copy(t);
if (r == t)
r = Copy(t);
q = SwigType_pop(r);
if (strstr(Char(r),"SWIGTYPE")) {
if (strstr(Char(r), "SWIGTYPE")) {
Delete(q);
def = r;
return def;
@ -387,20 +398,19 @@ SwigType *SwigType_default(SwigType *t) {
Delete(q);
}
cr = Char(r);
if (strcmp(cr,"p.SWIGTYPE") == 0) {
if (strcmp(cr, "p.SWIGTYPE") == 0) {
def = NewString("SWIGTYPE");
} else if (SwigType_ispointer(r)) {
#ifdef SWIG_NEW_TYPE_DEFAULT
SwigType *nr = Copy(r);
SwigType_del_pointer(nr);
def = SwigType_isfunction(nr) ?
NewStringEmpty() : NewString("p.");
def = SwigType_isfunction(nr) ? NewStringEmpty() : NewString("p.");
SwigType_add_default(def, nr);
Delete(nr);
#else
def = NewString("p.SWIGTYPE");
#endif
} else if (strcmp(cr,"r.SWIGTYPE") == 0) {
} else if (strcmp(cr, "r.SWIGTYPE") == 0) {
def = NewString("SWIGTYPE");
} else if (SwigType_isreference(r)) {
#ifdef SWIG_NEW_TYPE_DEFAULT
@ -413,19 +423,19 @@ SwigType *SwigType_default(SwigType *t) {
def = NewString("r.SWIGTYPE");
#endif
} else if (SwigType_isarray(r)) {
if (strcmp(cr,"a().SWIGTYPE") == 0) {
if (strcmp(cr, "a().SWIGTYPE") == 0) {
def = NewString("p.SWIGTYPE");
} else if (strcmp(cr,"a(ANY).SWIGTYPE") == 0) {
} else if (strcmp(cr, "a(ANY).SWIGTYPE") == 0) {
def = NewString("a().SWIGTYPE");
} else {
int i, empty = 0;
int ndim = SwigType_array_ndim(r);
SwigType *nr = Copy(r);
for (i = 0; i < ndim; i++) {
String *dim = SwigType_array_getdim(r,i);
String *dim = SwigType_array_getdim(r, i);
if (!Len(dim)) {
char *c = Char(nr);
empty = strstr(c,"a(ANY).") != c;
empty = strstr(c, "a(ANY).") != c;
}
Delete(dim);
}
@ -438,24 +448,24 @@ SwigType *SwigType_default(SwigType *t) {
SwigType_del_array(nr);
SwigType_add_default(def, nr);
#else
StringAppend(def,"SWIGTYPE");
StringAppend(def, "SWIGTYPE");
#endif
Delete(nr);
}
} else if (SwigType_ismemberpointer(r)) {
if (strcmp(cr,"m(CLASS).SWIGTYPE") == 0) {
if (strcmp(cr, "m(CLASS).SWIGTYPE") == 0) {
def = NewString("p.SWIGTYPE");
} else {
def = NewString("m(CLASS).SWIGTYPE");
}
} else if (SwigType_isenum(r)) {
if (strcmp(cr,"enum SWIGTYPE") == 0) {
if (strcmp(cr, "enum SWIGTYPE") == 0) {
def = NewString("SWIGTYPE");
} else {
def = NewString("enum SWIGTYPE");
}
} else if (SwigType_isfunction(r)) {
if (strcmp(cr,"f(ANY).SWIGTYPE") == 0) {
if (strcmp(cr, "f(ANY).SWIGTYPE") == 0) {
def = NewString("p.SWIGTYPE");
} else {
def = NewString("p.f(ANY).SWIGTYPE");
@ -463,17 +473,17 @@ SwigType *SwigType_default(SwigType *t) {
} else {
def = NewString("SWIGTYPE");
}
if (r != t) Delete(r);
if (StringEqual(def,t)) {
if (r != t)
Delete(r);
if (StringEqual(def, t)) {
Delete(def);
def = 0;
}
#ifdef SWIG_DEFAULT_CACHE
/* The cache produces strange results, see enum_template.i case */
if (def) {
String *cdef = Copy(def);
Setattr(default_cache,t, cdef);
String *cdef = Copy(def);
Setattr(default_cache, t, cdef);
Delete(cdef);
}
#endif
@ -489,35 +499,38 @@ SwigType *SwigType_default(SwigType *t) {
* Returns a string of the base type. Takes care of template expansions
* ----------------------------------------------------------------------------- */
String *
SwigType_namestr(const SwigType *t) {
String *SwigType_namestr(const SwigType *t) {
String *r;
String *suffix;
List *p;
int i, sz;
char *d = Char(t);
char *c = strstr(d,"<(");
List *p;
int i, sz;
char *d = Char(t);
char *c = strstr(d, "<(");
if (!c || !strstr(c+2,")>")) return NewString(t);
if (!c || !strstr(c + 2, ")>"))
return NewString(t);
r = NewStringWithSize(d, c - d);
if (*(c - 1) == '<') Putc(' ',r);
Putc('<',r);
p = SwigType_parmlist(c+1);
if (*(c - 1) == '<')
Putc(' ', r);
Putc('<', r);
p = SwigType_parmlist(c + 1);
sz = Len(p);
for (i = 0; i < sz; i++) {
String *str = SwigType_str(Getitem(p,i),0);
String *str = SwigType_str(Getitem(p, i), 0);
/* Avoid creating a <: token, which is the same as [ in C++. */
if (i == 0 && Len(str) && *Char(str) == ':') Putc(' ', r);
StringAppend(r,str);
if ((i+1) < sz) Putc(',',r);
if (i == 0 && Len(str) && *Char(str) == ':')
Putc(' ', r);
StringAppend(r, str);
if ((i + 1) < sz)
Putc(',', r);
Delete(str);
}
Putc(' ',r);
Putc('>',r);
Putc(' ', r);
Putc('>', r);
suffix = SwigType_templatesuffix(t);
StringAppend(r,suffix);
StringAppend(r, suffix);
Delete(suffix);
Delete(p);
return r;
@ -529,9 +542,7 @@ SwigType_namestr(const SwigType *t) {
* Create a C string representation of a datatype.
* ----------------------------------------------------------------------------- */
String *
SwigType_str(SwigType *s, const String_or_char *id)
{
String *SwigType_str(SwigType *s, const String_or_char *id) {
String *result;
String *element = 0, *nextelement;
List *elements;
@ -547,71 +558,71 @@ SwigType_str(SwigType *s, const String_or_char *id)
nelements = Len(elements);
if (nelements > 0) {
element = Getitem(elements,0);
element = Getitem(elements, 0);
}
/* Now, walk the type list and start emitting */
for (i = 0; i < nelements; i++) {
if (i < (nelements - 1)) {
nextelement = Getitem(elements,i+1);
nextelement = Getitem(elements, i + 1);
} else {
nextelement = 0;
}
if (SwigType_isqualifier(element)) {
DOH *q = 0;
q = SwigType_parm(element);
Insert(result,0," ");
Insert(result,0,q);
Insert(result, 0, " ");
Insert(result, 0, q);
Delete(q);
} else if (SwigType_ispointer(element)) {
Insert(result,0,"*");
Insert(result, 0, "*");
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
Insert(result,0,"(");
StringAppend(result,")");
Insert(result, 0, "(");
StringAppend(result, ")");
}
} else if (SwigType_ismemberpointer(element)) {
String *q;
q = SwigType_parm(element);
Insert(result,0,"::*");
Insert(result,0,q);
Insert(result, 0, "::*");
Insert(result, 0, q);
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
Insert(result,0,"(");
StringAppend(result,")");
Insert(result, 0, "(");
StringAppend(result, ")");
}
Delete(q);
}
else if (SwigType_isreference(element)) {
Insert(result,0,"&");
} else if (SwigType_isreference(element)) {
Insert(result, 0, "&");
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
Insert(result,0,"(");
StringAppend(result,")");
Insert(result, 0, "(");
StringAppend(result, ")");
}
} else if (SwigType_isarray(element)) {
} else if (SwigType_isarray(element)) {
DOH *size;
StringAppend(result,"[");
StringAppend(result, "[");
size = SwigType_parm(element);
StringAppend(result,size);
StringAppend(result,"]");
StringAppend(result, size);
StringAppend(result, "]");
Delete(size);
} else if (SwigType_isfunction(element)) {
DOH *parms, *p;
int j, plen;
StringAppend(result,"(");
StringAppend(result, "(");
parms = SwigType_parmlist(element);
plen = Len(parms);
for (j = 0; j < plen; j++) {
p = SwigType_str(Getitem(parms,j),0);
StringAppend(result,p);
if (j < (plen-1)) StringAppend(result,",");
p = SwigType_str(Getitem(parms, j), 0);
StringAppend(result, p);
if (j < (plen - 1))
StringAppend(result, ",");
}
StringAppend(result,")");
StringAppend(result, ")");
Delete(parms);
} else {
if (strcmp(Char(element),"v(...)") == 0) {
Insert(result,0,"...");
if (strcmp(Char(element), "v(...)") == 0) {
Insert(result, 0, "...");
} else {
String *bs = SwigType_namestr(element);
Insert(result,0," ");
Insert(result,0,bs);
Insert(result, 0, " ");
Insert(result, 0, bs);
Delete(bs);
}
}
@ -628,8 +639,7 @@ SwigType_str(SwigType *s, const String_or_char *id)
* Create a locally assignable type
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_ltype(SwigType *s) {
SwigType *SwigType_ltype(SwigType *s) {
String *result;
String *element;
SwigType *td, *tc = 0;
@ -646,9 +656,9 @@ SwigType_ltype(SwigType *s) {
}
if (SwigType_issimple(tc)) {
/* Resolve any typedef definitions */
SwigType *tt = Copy(tc);
SwigType *tt = Copy(tc);
td = 0;
while ((td = SwigType_typedef_resolve(tt))) {
while ((td = SwigType_typedef_resolve(tt))) {
if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) {
/* We need to use the typedef type */
Delete(tt);
@ -661,7 +671,7 @@ SwigType_ltype(SwigType *s) {
}
if (td) {
Delete(tc);
tc = td;
tc = td;
}
}
elements = SwigType_split(tc);
@ -669,7 +679,7 @@ SwigType_ltype(SwigType *s) {
/* Now, walk the type list and start emitting */
for (i = 0; i < nelements; i++) {
element = Getitem(elements,i);
element = Getitem(elements, i);
/* when we see a function, we need to preserve the following types */
if (SwigType_isfunction(element)) {
notypeconv = 1;
@ -677,34 +687,34 @@ SwigType_ltype(SwigType *s) {
if (SwigType_isqualifier(element)) {
/* Do nothing. Ignore */
} else if (SwigType_ispointer(element)) {
StringAppend(result,element);
StringAppend(result, element);
firstarray = 0;
} else if (SwigType_ismemberpointer(element)) {
StringAppend(result,element);
StringAppend(result, element);
firstarray = 0;
} else if (SwigType_isreference(element)) {
if (notypeconv) {
StringAppend(result,element);
StringAppend(result, element);
} else {
StringAppend(result,"p.");
StringAppend(result, "p.");
}
firstarray = 0;
} else if (SwigType_isarray(element) && firstarray) {
if (notypeconv) {
StringAppend(result,element);
StringAppend(result, element);
} else {
StringAppend(result,"p.");
StringAppend(result, "p.");
}
firstarray = 0;
} else if (SwigType_isenum(element)) {
int anonymous_enum = (Cmp(element,"enum ") == 0);
int anonymous_enum = (Cmp(element, "enum ") == 0);
if (notypeconv || !anonymous_enum) {
StringAppend(result,element);
StringAppend(result, element);
} else {
StringAppend(result,"int");
StringAppend(result, "int");
}
} else {
StringAppend(result,element);
StringAppend(result, element);
}
}
Delete(elements);
@ -727,14 +737,12 @@ SwigType_ltype(SwigType *s) {
* with an equivalent assignable version.
* -------------------------------------------------------------------- */
String *
SwigType_lstr(SwigType *s, const String_or_char *id)
{
String *SwigType_lstr(SwigType *s, const String_or_char *id) {
String *result;
SwigType *tc;
SwigType *tc;
tc = SwigType_ltype(s);
result = SwigType_str(tc,id);
result = SwigType_str(tc, id);
Delete(tc);
return result;
}
@ -751,11 +759,11 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
String *element = 0, *nextelement;
SwigType *td, *rs, *tc = 0;
List *elements;
int nelements, i;
int clear = 1;
int firstarray = 1;
int isreference = 0;
int isarray = 0;
int nelements, i;
int clear = 1;
int firstarray = 1;
int isreference = 0;
int isarray = 0;
result = NewStringEmpty();
@ -772,70 +780,70 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
} else {
td = SwigType_typedef_resolve(rs);
}
if (td) {
if ((SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td))) {
elements = SwigType_split(td);
} else {
elements = SwigType_split(rs);
}
}
Delete(td);
} else {
elements = SwigType_split(rs);
}
nelements = Len(elements);
if (nelements > 0) {
element = Getitem(elements,0);
element = Getitem(elements, 0);
}
/* Now, walk the type list and start emitting */
for (i = 0; i < nelements; i++) {
if (i < (nelements - 1)) {
nextelement = Getitem(elements,i+1);
nextelement = Getitem(elements, i + 1);
} else {
nextelement = 0;
}
if (SwigType_isqualifier(element)) {
DOH *q = 0;
q = SwigType_parm(element);
Insert(result,0," ");
Insert(result,0,q);
Insert(result, 0, " ");
Insert(result, 0, q);
Delete(q);
clear = 0;
} else if (SwigType_ispointer(element)) {
Insert(result,0,"*");
Insert(result, 0, "*");
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
Insert(result,0,"(");
StringAppend(result,")");
Insert(result, 0, "(");
StringAppend(result, ")");
}
firstarray = 0;
} else if (SwigType_ismemberpointer(element)) {
} else if (SwigType_ismemberpointer(element)) {
String *q;
Insert(result,0,"::*");
Insert(result, 0, "::*");
q = SwigType_parm(element);
Insert(result,0,q);
Insert(result, 0, q);
Delete(q);
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
Insert(result,0,"(");
StringAppend(result,")");
Insert(result, 0, "(");
StringAppend(result, ")");
}
firstarray = 0;
} else if (SwigType_isreference(element)) {
Insert(result,0,"&");
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
Insert(result,0,"(");
StringAppend(result,")");
}
isreference = 1;
Insert(result, 0, "&");
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
Insert(result, 0, "(");
StringAppend(result, ")");
}
isreference = 1;
} else if (SwigType_isarray(element)) {
DOH *size;
if (firstarray && !isreference) {
StringAppend(result,"(*)");
StringAppend(result, "(*)");
firstarray = 0;
} else {
StringAppend(result,"[");
StringAppend(result, "[");
size = SwigType_parm(element);
StringAppend(result,size);
StringAppend(result,"]");
StringAppend(result, size);
StringAppend(result, "]");
Delete(size);
clear = 0;
}
@ -843,21 +851,22 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
} else if (SwigType_isfunction(element)) {
DOH *parms, *p;
int j, plen;
StringAppend(result,"(");
StringAppend(result, "(");
parms = SwigType_parmlist(element);
plen = Len(parms);
for (j = 0; j < plen; j++) {
p = SwigType_str(Getitem(parms,j),0);
StringAppend(result,p);
p = SwigType_str(Getitem(parms, j), 0);
StringAppend(result, p);
Delete(p);
if (j < (plen-1)) StringAppend(result,",");
if (j < (plen - 1))
StringAppend(result, ",");
}
StringAppend(result,")");
StringAppend(result, ")");
Delete(parms);
} else {
String *bs = SwigType_namestr(element);
Insert(result,0," ");
Insert(result,0,bs);
Insert(result, 0, " ");
Insert(result, 0, bs);
Delete(bs);
}
element = nextelement;
@ -866,14 +875,15 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
if (clear) {
cast = NewStringEmpty();
} else {
cast = NewStringf("(%s)",result);
cast = NewStringf("(%s)", result);
}
if (name) {
if (isreference) {
if (isarray) Clear(cast);
StringAppend(cast,"*");
if (isarray)
Clear(cast);
StringAppend(cast, "*");
}
StringAppend(cast,name);
StringAppend(cast, name);
}
Delete(result);
Delete(tc);
@ -893,22 +903,22 @@ String *SwigType_lcaststr(SwigType *s, const String_or_char *name) {
result = NewStringEmpty();
if (SwigType_isarray(s)) {
String *lstr = SwigType_lstr(s,0);
Printf(result,"(%s)%s", lstr,name);
String *lstr = SwigType_lstr(s, 0);
Printf(result, "(%s)%s", lstr, name);
Delete(lstr);
} else if (SwigType_isreference(s)) {
String *str = SwigType_str(s,0);
Printf(result,"(%s)", str);
String *str = SwigType_str(s, 0);
Printf(result, "(%s)", str);
Delete(str);
if (name)
StringAppend(result,name);
if (name)
StringAppend(result, name);
} else if (SwigType_isqualifier(s)) {
String *lstr = SwigType_lstr(s,0);
Printf(result,"(%s)%s", lstr,name);
String *lstr = SwigType_lstr(s, 0);
Printf(result, "(%s)%s", lstr, name);
Delete(lstr);
} else {
if (name)
StringAppend(result,name);
StringAppend(result, name);
}
return result;
}
@ -922,11 +932,11 @@ String *SwigType_manglestr_default(SwigType *s) {
SwigType *lt;
SwigType *sr = SwigType_typedef_qualified(s);
SwigType *ss = SwigType_typedef_resolve_all(sr);
s = ss;
if (SwigType_istemplate(ss)) {
SwigType *ty = Swig_symbol_template_deftype(ss,0);
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
Delete(ss);
ss = ty;
s = ss;
@ -939,7 +949,8 @@ String *SwigType_manglestr_default(SwigType *s) {
c = Char(result);
while (*c) {
if (!isalnum((int)*c)) *c = '_';
if (!isalnum((int) *c))
*c = '_';
c++;
}
if (SwigType_istemplate(base)) {
@ -948,29 +959,39 @@ String *SwigType_manglestr_default(SwigType *s) {
base = b;
}
Replace(base,"struct ","", DOH_REPLACE_ANY); /* This might be problematic */
Replace(base,"class ","", DOH_REPLACE_ANY);
Replace(base,"union ","", DOH_REPLACE_ANY);
Replace(base,"enum ","", DOH_REPLACE_ANY);
Replace(base, "struct ", "", DOH_REPLACE_ANY); /* This might be problematic */
Replace(base, "class ", "", DOH_REPLACE_ANY);
Replace(base, "union ", "", DOH_REPLACE_ANY);
Replace(base, "enum ", "", DOH_REPLACE_ANY);
c = Char(base);
while (*c) {
if (*c == '<') *c = 'T';
else if (*c == '>') *c = 't';
else if (*c == '*') *c = 'p';
else if (*c == '[') *c = 'a';
else if (*c == ']') *c = 'A';
else if (*c == '&') *c = 'R';
else if (*c == '(') *c = 'f';
else if (*c == ')') *c = 'F';
else if (!isalnum((int)*c)) *c = '_';
if (*c == '<')
*c = 'T';
else if (*c == '>')
*c = 't';
else if (*c == '*')
*c = 'p';
else if (*c == '[')
*c = 'a';
else if (*c == ']')
*c = 'A';
else if (*c == '&')
*c = 'R';
else if (*c == '(')
*c = 'f';
else if (*c == ')')
*c = 'F';
else if (!isalnum((int) *c))
*c = '_';
c++;
}
StringAppend(result,base);
Insert(result,0,"_");
StringAppend(result, base);
Insert(result, 0, "_");
Delete(lt);
Delete(base);
if (ss) Delete(ss);
if (ss)
Delete(ss);
return result;
}
@ -984,51 +1005,52 @@ String *SwigType_manglestr(SwigType *s) {
* Replaces a typename in a type with something else. Needed for templates.
* ----------------------------------------------------------------------------- */
void
SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
void SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
String *nt;
int i, ilen;
List *elem;
int i, ilen;
List *elem;
if (!Strstr(t,pat)) return;
if (!Strstr(t, pat))
return;
if (StringEqual(t,pat)) {
Replace(t,pat,rep,DOH_REPLACE_ANY);
if (StringEqual(t, pat)) {
Replace(t, pat, rep, DOH_REPLACE_ANY);
return;
}
nt = NewStringEmpty();
elem = SwigType_split(t);
ilen = Len(elem);
for (i = 0; i < ilen; i++) {
String *e = Getitem(elem,i);
String *e = Getitem(elem, i);
if (SwigType_issimple(e)) {
if (StringEqual(e,pat)) {
if (StringEqual(e, pat)) {
/* Replaces a type of the form 'pat' with 'rep<args>' */
Replace(e,pat,rep,DOH_REPLACE_ANY);
Replace(e, pat, rep, DOH_REPLACE_ANY);
} else if (SwigType_istemplate(e)) {
/* Replaces a type of the form 'pat<args>' with 'rep' */
if (StringEqual(e,pat)) {
/* Replaces a type of the form 'pat<args>' with 'rep' */
if (StringEqual(e, pat)) {
String *repbase = SwigType_templateprefix(rep);
Replace(e,pat,repbase,DOH_REPLACE_ID | DOH_REPLACE_FIRST);
Replace(e, pat, repbase, DOH_REPLACE_ID | DOH_REPLACE_FIRST);
Delete(repbase);
}
}
{
String *tsuffix;
List *tparms = SwigType_parmlist(e);
int j, jlen;
String *nt = SwigType_templateprefix(e);
StringAppend(nt,"<(");
StringAppend(nt, "<(");
jlen = Len(tparms);
for (j = 0; j < jlen; j++) {
SwigType_typename_replace(Getitem(tparms,j), pat, rep);
StringAppend(nt,Getitem(tparms,j));
if (j < (jlen-1)) Putc(',',nt);
SwigType_typename_replace(Getitem(tparms, j), pat, rep);
StringAppend(nt, Getitem(tparms, j));
if (j < (jlen - 1))
Putc(',', nt);
}
tsuffix = SwigType_templatesuffix(e);
Printf(nt,")>%s", tsuffix);
Printf(nt, ")>%s", tsuffix);
Delete(tsuffix);
Clear(e);
StringAppend(e,nt);
StringAppend(e, nt);
Delete(nt);
Delete(tparms);
}
@ -1036,10 +1058,10 @@ SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
String *first, *rest;
first = Swig_scopename_first(e);
rest = Swig_scopename_suffix(e);
SwigType_typename_replace(rest,pat,rep);
SwigType_typename_replace(first,pat,rep);
SwigType_typename_replace(rest, pat, rep);
SwigType_typename_replace(first, pat, rep);
Clear(e);
Printv(e,first,"::",rest,NIL);
Printv(e, first, "::", rest, NIL);
Delete(first);
Delete(rest);
}
@ -1047,22 +1069,23 @@ SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
int j, jlen;
List *fparms = SwigType_parmlist(e);
Clear(e);
StringAppend(e,"f(");
StringAppend(e, "f(");
jlen = Len(fparms);
for (j = 0; j < jlen; j++) {
SwigType_typename_replace(Getitem(fparms,j), pat, rep);
StringAppend(e,Getitem(fparms,j));
if (j < (jlen-1)) Putc(',',e);
SwigType_typename_replace(Getitem(fparms, j), pat, rep);
StringAppend(e, Getitem(fparms, j));
if (j < (jlen - 1))
Putc(',', e);
}
StringAppend(e,").");
StringAppend(e, ").");
Delete(fparms);
} else if (SwigType_isarray(e)) {
Replace(e,pat,rep, DOH_REPLACE_ID);
Replace(e, pat, rep, DOH_REPLACE_ID);
}
StringAppend(nt,e);
StringAppend(nt, e);
}
Clear(t);
StringAppend(t,nt);
StringAppend(t, nt);
Delete(nt);
Delete(elem);
}
@ -1073,14 +1096,13 @@ SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
* Checks type declarators for a match
* ----------------------------------------------------------------------------- */
int
SwigType_check_decl(SwigType *ty, const SwigType *decl) {
SwigType *t,*t1,*t2;
int SwigType_check_decl(SwigType *ty, const SwigType *decl) {
SwigType *t, *t1, *t2;
int r;
t = SwigType_typedef_resolve_all(ty);
t1 = SwigType_strip_qualifiers(t);
t2 = SwigType_prefix(t1);
r = Equal(t2,decl);
r = Equal(t2, decl);
Delete(t);
Delete(t1);
Delete(t2);

View file

@ -35,17 +35,17 @@ extern "C" {
/* Short names for common data types */
typedef DOH String;
typedef DOH Hash;
typedef DOH List;
typedef DOH String_or_char;
typedef DOH File;
typedef DOH Parm;
typedef DOH ParmList;
typedef DOH Node;
typedef DOH Symtab;
typedef DOH Typetab;
typedef DOH SwigType;
typedef DOH String;
typedef DOH Hash;
typedef DOH List;
typedef DOH String_or_char;
typedef DOH File;
typedef DOH Parm;
typedef DOH ParmList;
typedef DOH Node;
typedef DOH Symtab;
typedef DOH Typetab;
typedef DOH SwigType;
/* --- Legacy DataType interface. These type codes are provided solely
for backwards compatibility with older modules --- */
@ -94,28 +94,28 @@ typedef DOH SwigType;
/* --- File interface --- */
extern List *Swig_add_directory(const String_or_char *dirname);
extern void Swig_push_directory(const String_or_char *dirname);
extern void Swig_pop_directory();
extern String *Swig_last_file();
extern List *Swig_search_path();
extern FILE *Swig_open(const String_or_char *name);
extern String *Swig_read_file(FILE *f);
extern String *Swig_include(const String_or_char *name);
extern String *Swig_include_sys(const String_or_char *name);
extern int Swig_insert_file(const String_or_char *name, File *outfile);
extern void Swig_set_config_file(const String_or_char *filename);
extern String *Swig_get_config_file(void);
extern void Swig_set_push_dir(int dopush);
extern int Swig_get_push_dir(void);
extern void Swig_swiglib_set(const String_or_char *);
extern String *Swig_swiglib_get();
extern void Swig_register_filebyname(const String_or_char *filename, File *outfile);
extern File *Swig_filebyname(const String_or_char *filename);
extern char *Swig_file_suffix(const String_or_char *filename);
extern char *Swig_file_basename(const String_or_char *filename);
extern char *Swig_file_filename(const String_or_char *filename);
extern char *Swig_file_dirname(const String_or_char *filename);
extern List *Swig_add_directory(const String_or_char *dirname);
extern void Swig_push_directory(const String_or_char *dirname);
extern void Swig_pop_directory();
extern String *Swig_last_file();
extern List *Swig_search_path();
extern FILE *Swig_open(const String_or_char *name);
extern String *Swig_read_file(FILE *f);
extern String *Swig_include(const String_or_char *name);
extern String *Swig_include_sys(const String_or_char *name);
extern int Swig_insert_file(const String_or_char *name, File *outfile);
extern void Swig_set_config_file(const String_or_char *filename);
extern String *Swig_get_config_file(void);
extern void Swig_set_push_dir(int dopush);
extern int Swig_get_push_dir(void);
extern void Swig_swiglib_set(const String_or_char *);
extern String *Swig_swiglib_get();
extern void Swig_register_filebyname(const String_or_char *filename, File *outfile);
extern File *Swig_filebyname(const String_or_char *filename);
extern char *Swig_file_suffix(const String_or_char *filename);
extern char *Swig_file_basename(const String_or_char *filename);
extern char *Swig_file_filename(const String_or_char *filename);
extern char *Swig_file_dirname(const String_or_char *filename);
#if defined(MACSWIG)
# define SWIG_FILE_DELIMETER ":"
@ -127,32 +127,32 @@ extern char *Swig_file_dirname(const String_or_char *filename);
/* --- Command line parsing --- */
extern void Swig_init_args(int argc, char **argv);
extern void Swig_mark_arg(int n);
extern int Swig_check_marked(int n);
extern void Swig_check_options(int check_input);
extern void Swig_arg_error();
extern void Swig_init_args(int argc, char **argv);
extern void Swig_mark_arg(int n);
extern int Swig_check_marked(int n);
extern void Swig_check_options(int check_input);
extern void Swig_arg_error();
/* --- Scanner Interface --- */
typedef struct SwigScanner SwigScanner;
typedef struct SwigScanner SwigScanner;
extern SwigScanner *NewSwigScanner();
extern void DelSwigScanner(SwigScanner *);
extern void SwigScanner_clear(SwigScanner *);
extern void SwigScanner_push(SwigScanner *, String *);
extern void SwigScanner_pushtoken(SwigScanner *, int);
extern int SwigScanner_token(SwigScanner *);
extern String *SwigScanner_text(SwigScanner *);
extern void SwigScanner_skip_line(SwigScanner *);
extern int SwigScanner_skip_balanced(SwigScanner *, int startchar, int endchar);
extern void SwigScanner_set_location(SwigScanner *, String *file, int line);
extern String *SwigScanner_get_file(SwigScanner *);
extern int SwigScanner_get_line(SwigScanner *);
extern void SwigScanner_idstart(SwigScanner *, char *idchar);
extern SwigScanner *NewSwigScanner();
extern void DelSwigScanner(SwigScanner *);
extern void SwigScanner_clear(SwigScanner *);
extern void SwigScanner_push(SwigScanner *, String *);
extern void SwigScanner_pushtoken(SwigScanner *, int);
extern int SwigScanner_token(SwigScanner *);
extern String *SwigScanner_text(SwigScanner *);
extern void SwigScanner_skip_line(SwigScanner *);
extern int SwigScanner_skip_balanced(SwigScanner *, int startchar, int endchar);
extern void SwigScanner_set_location(SwigScanner *, String *file, int line);
extern String *SwigScanner_get_file(SwigScanner *);
extern int SwigScanner_get_line(SwigScanner *);
extern void SwigScanner_idstart(SwigScanner *, char *idchar);
#define SWIG_MAXTOKENS 512
#define SWIG_TOKEN_LPAREN 1
#define SWIG_TOKEN_LPAREN 1
#define SWIG_TOKEN_RPAREN 2
#define SWIG_TOKEN_SEMI 3
#define SWIG_TOKEN_COMMA 4
@ -203,146 +203,146 @@ extern void SwigScanner_idstart(SwigScanner *, char *idchar);
#define SWIG_TOKEN_LONGLONG 49
#define SWIG_TOKEN_ULONGLONG 50
#define SWIG_TOKEN_ILLEGAL 98
#define SWIG_TOKEN_LAST 99
#define SWIG_TOKEN_LAST 99
/* --- Functions for manipulating the string-based type encoding --- */
extern SwigType *NewSwigType(int typecode);
extern SwigType *SwigType_del_element(SwigType *t);
extern SwigType *SwigType_add_pointer(SwigType *t);
extern SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *qual);
extern SwigType *SwigType_del_pointer(SwigType *t);
extern SwigType *SwigType_add_array(SwigType *t, const String_or_char *size);
extern SwigType *SwigType_del_array(SwigType *t);
extern SwigType *SwigType_pop_arrays(SwigType *t);
extern SwigType *SwigType_add_reference(SwigType *t);
extern SwigType *SwigType_del_reference(SwigType *t);
extern SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual);
extern SwigType *SwigType_del_qualifier(SwigType *t);
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
extern SwigType *SwigType_pop_function(SwigType *t);
extern ParmList *SwigType_function_parms(SwigType *t);
extern List *SwigType_split(const SwigType *t);
extern String *SwigType_pop(SwigType *t);
extern void SwigType_push(SwigType *t, SwigType *s);
extern List *SwigType_parmlist(const SwigType *p);
extern String *SwigType_parm(String *p);
extern String *SwigType_str(SwigType *s, const String_or_char *id);
extern String *SwigType_lstr(SwigType *s, const String_or_char *id);
extern String *SwigType_rcaststr(SwigType *s, const String_or_char *id);
extern String *SwigType_lcaststr(SwigType *s, const String_or_char *id);
extern String *SwigType_manglestr(SwigType *t);
extern SwigType *SwigType_ltype(SwigType *t);
extern int SwigType_ispointer(SwigType *t);
extern int SwigType_ispointer_return(SwigType *t);
extern int SwigType_ismemberpointer(SwigType *t);
extern int SwigType_isreference(SwigType *t);
extern int SwigType_isreference_return(SwigType *t);
extern int SwigType_isarray(SwigType *t);
extern int SwigType_isfunction(SwigType *t);
extern int SwigType_isqualifier(SwigType *t);
extern int SwigType_isconst(SwigType *t);
extern int SwigType_issimple(SwigType *t);
extern int SwigType_ismutable(SwigType *t);
extern int SwigType_isvarargs(const SwigType *t);
extern int SwigType_istemplate(const SwigType *t);
extern int SwigType_isenum(SwigType *t);
extern int SwigType_check_decl(SwigType *t, const String_or_char *decl);
extern SwigType *SwigType_strip_qualifiers(SwigType *t);
extern String *SwigType_base(const SwigType *t);
extern String *SwigType_namestr(const SwigType *t);
extern String *SwigType_templateprefix(const SwigType *t);
extern String *SwigType_templatesuffix(const SwigType *t);
extern String *SwigType_templateargs(const SwigType *t);
extern String *SwigType_prefix(const SwigType *t);
extern int SwigType_array_ndim(SwigType *t);
extern String *SwigType_array_getdim(SwigType *t, int n);
extern void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep);
extern SwigType *SwigType_array_type(SwigType *t);
extern String *SwigType_default(SwigType *t);
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
extern SwigType *SwigType_alttype(SwigType *t, int ltmap);
extern SwigType *NewSwigType(int typecode);
extern SwigType *SwigType_del_element(SwigType *t);
extern SwigType *SwigType_add_pointer(SwigType *t);
extern SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *qual);
extern SwigType *SwigType_del_pointer(SwigType *t);
extern SwigType *SwigType_add_array(SwigType *t, const String_or_char *size);
extern SwigType *SwigType_del_array(SwigType *t);
extern SwigType *SwigType_pop_arrays(SwigType *t);
extern SwigType *SwigType_add_reference(SwigType *t);
extern SwigType *SwigType_del_reference(SwigType *t);
extern SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual);
extern SwigType *SwigType_del_qualifier(SwigType *t);
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
extern SwigType *SwigType_pop_function(SwigType *t);
extern ParmList *SwigType_function_parms(SwigType *t);
extern List *SwigType_split(const SwigType *t);
extern String *SwigType_pop(SwigType *t);
extern void SwigType_push(SwigType *t, SwigType *s);
extern List *SwigType_parmlist(const SwigType *p);
extern String *SwigType_parm(String *p);
extern String *SwigType_str(SwigType *s, const String_or_char *id);
extern String *SwigType_lstr(SwigType *s, const String_or_char *id);
extern String *SwigType_rcaststr(SwigType *s, const String_or_char *id);
extern String *SwigType_lcaststr(SwigType *s, const String_or_char *id);
extern String *SwigType_manglestr(SwigType *t);
extern SwigType *SwigType_ltype(SwigType *t);
extern int SwigType_ispointer(SwigType *t);
extern int SwigType_ispointer_return(SwigType *t);
extern int SwigType_ismemberpointer(SwigType *t);
extern int SwigType_isreference(SwigType *t);
extern int SwigType_isreference_return(SwigType *t);
extern int SwigType_isarray(SwigType *t);
extern int SwigType_isfunction(SwigType *t);
extern int SwigType_isqualifier(SwigType *t);
extern int SwigType_isconst(SwigType *t);
extern int SwigType_issimple(SwigType *t);
extern int SwigType_ismutable(SwigType *t);
extern int SwigType_isvarargs(const SwigType *t);
extern int SwigType_istemplate(const SwigType *t);
extern int SwigType_isenum(SwigType *t);
extern int SwigType_check_decl(SwigType *t, const String_or_char *decl);
extern SwigType *SwigType_strip_qualifiers(SwigType *t);
extern String *SwigType_base(const SwigType *t);
extern String *SwigType_namestr(const SwigType *t);
extern String *SwigType_templateprefix(const SwigType *t);
extern String *SwigType_templatesuffix(const SwigType *t);
extern String *SwigType_templateargs(const SwigType *t);
extern String *SwigType_prefix(const SwigType *t);
extern int SwigType_array_ndim(SwigType *t);
extern String *SwigType_array_getdim(SwigType *t, int n);
extern void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep);
extern SwigType *SwigType_array_type(SwigType *t);
extern String *SwigType_default(SwigType *t);
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
extern SwigType *SwigType_alttype(SwigType *t, int ltmap);
extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
extern SwigType* SwigType_template_deftype(const SwigType *type, Symtab *tscope);
extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
extern SwigType *SwigType_template_deftype(const SwigType *type, Symtab *tscope);
/* --- Type-system managment --- */
extern void SwigType_typesystem_init();
extern int SwigType_typedef(SwigType *type, String_or_char *name);
extern int SwigType_typedef_class(String_or_char *name);
extern int SwigType_typedef_using(String_or_char *qname);
extern void SwigType_inherit(String *subclass, String *baseclass, String *cast);
extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype);
extern void SwigType_scope_alias(String *aliasname, Typetab *t);
extern void SwigType_using_scope(Typetab *t);
extern void SwigType_new_scope(const String_or_char *name);
extern void SwigType_inherit_scope(Typetab *scope);
extern Typetab *SwigType_pop_scope();
extern Typetab *SwigType_set_scope(Typetab *h);
extern void SwigType_print_scope(Typetab *t);
extern SwigType *SwigType_typedef_resolve(SwigType *t);
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
extern SwigType *SwigType_typedef_qualified(SwigType *t);
extern int SwigType_istypedef(SwigType *t);
extern int SwigType_isclass(SwigType *t);
extern void SwigType_attach_symtab(Symtab *syms);
extern void SwigType_remember(SwigType *t);
extern void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata);
extern void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata);
extern void (*SwigType_remember_trace(void (*tf)(SwigType *, String *, String *)))(SwigType *, String *, String *);
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
extern int SwigType_type(SwigType *t);
extern void SwigType_typesystem_init();
extern int SwigType_typedef(SwigType *type, String_or_char *name);
extern int SwigType_typedef_class(String_or_char *name);
extern int SwigType_typedef_using(String_or_char *qname);
extern void SwigType_inherit(String *subclass, String *baseclass, String *cast);
extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype);
extern void SwigType_scope_alias(String *aliasname, Typetab *t);
extern void SwigType_using_scope(Typetab *t);
extern void SwigType_new_scope(const String_or_char *name);
extern void SwigType_inherit_scope(Typetab *scope);
extern Typetab *SwigType_pop_scope();
extern Typetab *SwigType_set_scope(Typetab *h);
extern void SwigType_print_scope(Typetab *t);
extern SwigType *SwigType_typedef_resolve(SwigType *t);
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
extern SwigType *SwigType_typedef_qualified(SwigType *t);
extern int SwigType_istypedef(SwigType *t);
extern int SwigType_isclass(SwigType *t);
extern void SwigType_attach_symtab(Symtab *syms);
extern void SwigType_remember(SwigType *t);
extern void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata);
extern void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata);
extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *);
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
extern int SwigType_type(SwigType *t);
/* --- Symbol table module --- */
extern void Swig_symbol_init();
extern void Swig_symbol_setscopename(const String_or_char *name);
extern String *Swig_symbol_getscopename();
extern String *Swig_symbol_qualifiedscopename(Symtab *symtab);
extern Symtab *Swig_symbol_newscope();
extern Symtab *Swig_symbol_setscope(Symtab *);
extern Symtab *Swig_symbol_getscope(const String_or_char *symname);
extern Symtab *Swig_symbol_current();
extern Symtab *Swig_symbol_popscope();
extern Node *Swig_symbol_add(String_or_char *symname, Node *node);
extern void Swig_symbol_cadd(String_or_char *symname, Node *node);
extern Node *Swig_symbol_clookup(String_or_char *symname, Symtab *tab);
extern Node *Swig_symbol_clookup_check(String_or_char *symname, Symtab *tab, int (*check)(Node *));
extern Symtab *Swig_symbol_cscope(String_or_char *symname, Symtab *tab);
extern Node *Swig_symbol_clookup_local(String_or_char *symname, Symtab *tab);
extern Node *Swig_symbol_clookup_local_check(String_or_char *symname, Symtab *tab, int (*check)(Node *));
extern String *Swig_symbol_qualified(Node *node);
extern Node *Swig_symbol_isoverloaded(Node *node);
extern void Swig_symbol_remove(Node *node);
extern void Swig_symbol_alias(String_or_char *aliasname, Symtab *tab);
extern void Swig_symbol_inherit(Symtab *tab);
extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab);
extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
extern SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab);
extern void Swig_symbol_init();
extern void Swig_symbol_setscopename(const String_or_char *name);
extern String *Swig_symbol_getscopename();
extern String *Swig_symbol_qualifiedscopename(Symtab *symtab);
extern Symtab *Swig_symbol_newscope();
extern Symtab *Swig_symbol_setscope(Symtab *);
extern Symtab *Swig_symbol_getscope(const String_or_char *symname);
extern Symtab *Swig_symbol_current();
extern Symtab *Swig_symbol_popscope();
extern Node *Swig_symbol_add(String_or_char *symname, Node *node);
extern void Swig_symbol_cadd(String_or_char *symname, Node *node);
extern Node *Swig_symbol_clookup(String_or_char *symname, Symtab *tab);
extern Node *Swig_symbol_clookup_check(String_or_char *symname, Symtab *tab, int (*check) (Node *));
extern Symtab *Swig_symbol_cscope(String_or_char *symname, Symtab *tab);
extern Node *Swig_symbol_clookup_local(String_or_char *symname, Symtab *tab);
extern Node *Swig_symbol_clookup_local_check(String_or_char *symname, Symtab *tab, int (*check) (Node *));
extern String *Swig_symbol_qualified(Node *node);
extern Node *Swig_symbol_isoverloaded(Node *node);
extern void Swig_symbol_remove(Node *node);
extern void Swig_symbol_alias(String_or_char *aliasname, Symtab *tab);
extern void Swig_symbol_inherit(Symtab *tab);
extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab);
extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
extern SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab);
extern void Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
extern SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab);
extern void Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
extern SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab);
/* --- Parameters and Parameter Lists --- */
/* Parameters are really just hidden behind a DOH object. The following
interface will probably be simplified even further. */
extern Parm *NewParm(SwigType *type, const String_or_char *name);
extern Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n);
extern Parm *CopyParm(Parm *p);
extern ParmList *CopyParmList(ParmList *);
extern int ParmList_len(ParmList *);
extern int ParmList_numarg(ParmList *);
extern int ParmList_numrequired(ParmList *);
extern String *ParmList_str(ParmList *);
extern String *ParmList_str_defaultargs(ParmList *);
extern String *ParmList_protostr(ParmList *);
extern int ParmList_is_compactdefargs(ParmList *p);
extern int ParmList_has_defaultargs(ParmList *p);
extern ParmList *ParmList_copy_all_except_last_parm(ParmList *p);
extern Parm *NewParm(SwigType *type, const String_or_char *name);
extern Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n);
extern Parm *CopyParm(Parm *p);
extern ParmList *CopyParmList(ParmList *);
extern int ParmList_len(ParmList *);
extern int ParmList_numarg(ParmList *);
extern int ParmList_numrequired(ParmList *);
extern String *ParmList_str(ParmList *);
extern String *ParmList_str_defaultargs(ParmList *);
extern String *ParmList_protostr(ParmList *);
extern int ParmList_is_compactdefargs(ParmList *p);
extern int ParmList_has_defaultargs(ParmList *p);
extern ParmList *ParmList_copy_all_except_last_parm(ParmList *p);
/* --- Parse tree support --- */
@ -354,7 +354,7 @@ extern ParmList *ParmList_copy_all_except_last_parm(ParmList *p);
#define nextSibling(x) Getattr(x,k_nextsibling)
#define firstChild(x) Getattr(x,k_firstchild)
#define lastChild(x) Getattr(x,k_lastchild)
extern int checkAttribute(Node *obj, const String_or_char *name, const String_or_char *value);
extern int checkAttribute(Node *obj, const String_or_char *name, const String_or_char *value);
/* Macros to set up the DOM tree (mostly used by the parser) */
@ -365,145 +365,142 @@ extern int checkAttribute(Node *obj, const String_or_char *name, const String_or
#define set_firstChild(x,v) Setattr(x,"firstChild",v)
#define set_lastChild(x,v) Setattr(x,"lastChild",v)
extern void appendChild(Node *node, Node *child);
extern void preppendChild(Node *node, Node *child);
extern void deleteNode(Node *node);
extern Node *copyNode(Node *node);
extern void appendChild(Node *node, Node *child);
extern void preppendChild(Node *node, Node *child);
extern void deleteNode(Node *node);
extern Node *copyNode(Node *node);
extern void Swig_tag_nodes(Node *node, const String_or_char *attrname, DOH *value);
extern void Swig_tag_nodes(Node *node, const String_or_char *attrname, DOH *value);
extern int Swig_require(const char *ns, Node *node, ...);
extern int Swig_save(const char *ns, Node *node,...);
extern void Swig_restore(Node *node);
extern int Swig_require(const char *ns, Node *node, ...);
extern int Swig_save(const char *ns, Node *node, ...);
extern void Swig_restore(Node *node);
/* Debugging of parse trees */
extern void Swig_print_tags(File *obj, Node *root);
extern void Swig_print_tree(Node *obj);
extern void Swig_print_node(Node *obj);
extern void Swig_print_tags(File *obj, Node *root);
extern void Swig_print_tree(Node *obj);
extern void Swig_print_node(Node *obj);
extern void Swig_print_xml(Node *obj, String* filename);
extern void Swig_print_xml(Node *obj, String *filename);
/* -- Wrapper function Object */
typedef struct {
Hash *localh;
String *def;
String *locals;
String *code;
} Wrapper;
typedef struct {
Hash *localh;
String *def;
String *locals;
String *code;
} Wrapper;
extern Wrapper *NewWrapper();
extern void DelWrapper(Wrapper *w);
extern void Wrapper_compact_print_mode_set(int flag);
extern void Wrapper_pretty_print(String *str, File *f);
extern void Wrapper_compact_print(String *str, File *f);
extern void Wrapper_print(Wrapper *w, File *f);
extern int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
extern int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...);
extern int Wrapper_check_local(Wrapper *w, const String_or_char *name);
extern char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
extern char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...);
extern Wrapper *NewWrapper();
extern void DelWrapper(Wrapper *w);
extern void Wrapper_compact_print_mode_set(int flag);
extern void Wrapper_pretty_print(String *str, File *f);
extern void Wrapper_compact_print(String *str, File *f);
extern void Wrapper_print(Wrapper *w, File *f);
extern int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
extern int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...);
extern int Wrapper_check_local(Wrapper *w, const String_or_char *name);
extern char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
extern char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...);
/* --- Naming functions --- */
extern void Swig_name_register(const String_or_char *method, const String_or_char *format);
extern void Swig_name_unregister(const String_or_char *method);
extern String *Swig_name_mangle(const String_or_char *s);
extern String *Swig_name_wrapper(const String_or_char *fname);
extern String *Swig_name_member(const String_or_char *classname, const String_or_char *mname);
extern String *Swig_name_get(const String_or_char *vname);
extern String *Swig_name_set(const String_or_char *vname);
extern String *Swig_name_construct(const String_or_char *classname);
extern String *Swig_name_copyconstructor(const String_or_char *classname);
extern String *Swig_name_destroy(const String_or_char *classname);
extern String *Swig_name_disown(const String_or_char *classname);
extern void Swig_name_register(const String_or_char *method, const String_or_char *format);
extern void Swig_name_unregister(const String_or_char *method);
extern String *Swig_name_mangle(const String_or_char *s);
extern String *Swig_name_wrapper(const String_or_char *fname);
extern String *Swig_name_member(const String_or_char *classname, const String_or_char *mname);
extern String *Swig_name_get(const String_or_char *vname);
extern String *Swig_name_set(const String_or_char *vname);
extern String *Swig_name_construct(const String_or_char *classname);
extern String *Swig_name_copyconstructor(const String_or_char *classname);
extern String *Swig_name_destroy(const String_or_char *classname);
extern String *Swig_name_disown(const String_or_char *classname);
extern void Swig_naming_init();
extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
extern Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name,SwigType *decl);
extern void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *namewrn, ParmList *declaratorparms);
extern void Swig_name_inherit(String *base, String *derived);
extern int Swig_need_protected(Node *n);
extern int Swig_need_name_warning(Node *n);
extern int Swig_need_redefined_warn(Node* a, Node* b, int InClass);
extern void Swig_naming_init();
extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
extern Hash *Swig_name_namewarn_get(Node *n, String *prefix, String *name, SwigType *decl);
extern void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *namewrn, ParmList *declaratorparms);
extern void Swig_name_inherit(String *base, String *derived);
extern int Swig_need_protected(Node *n);
extern int Swig_need_name_warning(Node *n);
extern int Swig_need_redefined_warn(Node *a, Node *b, int InClass);
extern String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname);
extern String *Swig_name_warning(Node *n, String *prefix, String *name,SwigType *decl);
extern String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname);
extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl);
/* --- parameterized rename functions --- */
extern void Swig_name_object_set(Hash *namehash, String_or_char *name, SwigType *decl, DOH *object);
extern DOH *Swig_name_object_get(Hash *namehash, String_or_char *prefix, String_or_char *name, SwigType *decl);
extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived);
extern void Swig_features_get(Hash *features, String_or_char *prefix, String_or_char *name, SwigType *decl, Node *n);
extern void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs);
extern void Swig_name_object_set(Hash *namehash, String_or_char *name, SwigType *decl, DOH *object);
extern DOH *Swig_name_object_get(Hash *namehash, String_or_char *prefix, String_or_char *name, SwigType *decl);
extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived);
extern void Swig_features_get(Hash *features, String_or_char *prefix, String_or_char *name, SwigType *decl, Node *n);
extern void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value,
Hash *featureattribs);
/* --- Misc --- */
extern char *Swig_copy_string(const char *c);
extern void Swig_banner(File *f);
extern String *Swig_string_escape(String *s);
extern String *Swig_string_mangle(const String *s);
extern void Swig_scopename_split(String *s, String **prefix, String **last);
extern String *Swig_scopename_prefix(String *s);
extern String *Swig_scopename_last(String *s);
extern String *Swig_scopename_first(String *s);
extern String *Swig_scopename_suffix(String *s);
extern int Swig_scopename_check(String *s);
extern String *Swig_string_lower(String *s);
extern String *Swig_string_upper(String *s);
extern String *Swig_string_title(String *s);
extern char *Swig_copy_string(const char *c);
extern void Swig_banner(File *f);
extern String *Swig_string_escape(String *s);
extern String *Swig_string_mangle(const String *s);
extern void Swig_scopename_split(String *s, String **prefix, String **last);
extern String *Swig_scopename_prefix(String *s);
extern String *Swig_scopename_last(String *s);
extern String *Swig_scopename_first(String *s);
extern String *Swig_scopename_suffix(String *s);
extern int Swig_scopename_check(String *s);
extern String *Swig_string_lower(String *s);
extern String *Swig_string_upper(String *s);
extern String *Swig_string_title(String *s);
extern void Swig_init();
extern void Swig_warn(const char *filename, int line, const char *msg);
extern void Swig_init();
extern void Swig_warn(const char *filename, int line, const char *msg);
extern int Swig_value_wrapper_mode(int mode);
extern int Swig_value_wrapper_mode(int mode);
#define WARNING(msg) Swig_warn(__FILE__,__LINE__,msg)
typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat;
typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat;
extern void Swig_warning(int num, const String_or_char *filename, int line, const char *fmt, ...);
extern void Swig_error(const String_or_char *filename, int line, const char *fmt, ...);
extern int Swig_error_count(void);
extern void Swig_error_silent(int s);
extern void Swig_warnfilter(const String_or_char *wlist, int val);
extern void Swig_warnall(void);
extern int Swig_warn_count(void);
extern void Swig_error_msg_format(ErrorMessageFormat format);
extern void Swig_warning(int num, const String_or_char *filename, int line, const char *fmt, ...);
extern void Swig_error(const String_or_char *filename, int line, const char *fmt, ...);
extern int Swig_error_count(void);
extern void Swig_error_silent(int s);
extern void Swig_warnfilter(const String_or_char *wlist, int val);
extern void Swig_warnall(void);
extern int Swig_warn_count(void);
extern void Swig_error_msg_format(ErrorMessageFormat format);
/* --- C Wrappers --- */
extern String *Swig_cparm_name(Parm *p, int i);
extern String *Swig_wrapped_var_type(SwigType *t, int varcref);
extern int Swig_cargs(Wrapper *w, ParmList *l);
extern String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl);
extern String *Swig_cparm_name(Parm *p, int i);
extern String *Swig_wrapped_var_type(SwigType *t, int varcref);
extern int Swig_cargs(Wrapper *w, ParmList *l);
extern String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl);
extern String *Swig_cfunction_call(String_or_char *name, ParmList *parms);
extern String *Swig_cconstructor_call(String_or_char *name);
extern String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms);
extern String *Swig_unref_call(Node *n);
extern String *Swig_ref_call(Node *n, const String* lname);
extern String *Swig_cdestructor_call(Node *n);
extern String *Swig_cppdestructor_call(Node *n);
extern String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref);
extern String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref);
extern String *Swig_cfunction_call(String_or_char *name, ParmList *parms);
extern String *Swig_cconstructor_call(String_or_char *name);
extern String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms);
extern String *Swig_unref_call(Node *n);
extern String *Swig_ref_call(Node *n, const String *lname);
extern String *Swig_cdestructor_call(Node *n);
extern String *Swig_cppdestructor_call(Node *n);
extern String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref);
extern String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref);
extern String *Swig_extension_code(const String *function_name,
ParmList *parms, SwigType* return_type, const String *code, int cplusplus);
extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType* return_type, const String *code, int cplusplus);
extern String *Swig_extension_code(const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus);
extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus);
/* --- Transformations --- */
extern int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director);
extern int Swig_ConstructorToFunction(Node *n, String *classname,
String *none_comparison,
String *director_ctor,
int cplus, int flags);
extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags);
extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
extern int Swig_VargetToFunction(Node *n, int flags);
extern int Swig_VarsetToFunction(Node *n, int flags);
extern int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director);
extern int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags);
extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
extern int Swig_VargetToFunction(Node *n, int flags);
extern int Swig_VarsetToFunction(Node *n, int flags);
#define CWRAP_EXTEND 0x01
#define CWRAP_SMART_POINTER 0x02
@ -512,49 +509,47 @@ extern int Swig_VarsetToFunction(Node *n, int flags);
#define CWRAP_DIRECTOR_TWO_CALLS 0x10
/* --- Director Helpers --- */
extern Node *Swig_methodclass(Node *n);
extern int Swig_directorclass(Node *n);
extern Node *Swig_directormap(Node *n, String *type);
extern Node *Swig_methodclass(Node *n);
extern int Swig_directorclass(Node *n);
extern Node *Swig_directormap(Node *n, String *type);
/* --- Legacy Typemap API (somewhat simplified, ha!) --- */
extern void Swig_typemap_init();
extern void Swig_typemap_register(const String_or_char *op, ParmList *pattern, String_or_char *code, ParmList *locals, ParmList *kwargs);
extern int Swig_typemap_copy(const String_or_char *op, ParmList *srcpattern, ParmList *pattern);
extern void Swig_typemap_clear(const String_or_char *op, ParmList *pattern);
extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat);
extern void Swig_typemap_clear_apply(ParmList *pattern);
extern void Swig_typemap_debug();
extern void Swig_typemap_init();
extern void Swig_typemap_register(const String_or_char *op, ParmList *pattern, String_or_char *code, ParmList *locals, ParmList *kwargs);
extern int Swig_typemap_copy(const String_or_char *op, ParmList *srcpattern, ParmList *pattern);
extern void Swig_typemap_clear(const String_or_char *op, ParmList *pattern);
extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat);
extern void Swig_typemap_clear_apply(ParmList *pattern);
extern void Swig_typemap_debug();
extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *pname, SwigType **matchtype);
extern Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch);
extern String *Swig_typemap_lookup(const String_or_char *op, SwigType *type, String_or_char *pname, String_or_char *lname,
String_or_char *source, String_or_char *target, Wrapper *f);
extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *pname, SwigType **matchtype);
extern Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch);
extern String *Swig_typemap_lookup(const String_or_char *op, SwigType *type, String_or_char *pname, String_or_char *lname,
String_or_char *source, String_or_char *target, Wrapper *f);
extern String *Swig_typemap_lookup_new(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f);
extern void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p);
extern void Swig_typemap_new_scope();
extern Hash *Swig_typemap_pop_scope();
extern String *Swig_typemap_lookup_new(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f);
extern void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p);
extern void Swig_typemap_new_scope();
extern Hash *Swig_typemap_pop_scope();
extern void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f);
extern void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f);
/* --- Code fragment support --- */
extern void Swig_fragment_register(Node* fragment);
extern void Swig_fragment_emit(String *name);
extern void Swig_fragment_register(Node *fragment);
extern void Swig_fragment_emit(String *name);
/* hacks defined in C++ ! */
extern int Swig_director_mode();
extern void Wrapper_director_mode_set(int);
extern int Swig_director_mode();
extern void Wrapper_director_mode_set(int);
/* -- template init -- */
extern void SwigType_template_init();
extern void SwigType_template_init();
#ifdef __cplusplus
}
#endif
#endif

View file

@ -261,6 +261,6 @@ void Swig_keys_init() {
k_previoussibling = NewString("previousSibling");
k_nextsibling = NewString("nextSibling");
k_firstchild = NewString("firstChild");
k_lastchild = NewString("lastChild");
k_firstchild = NewString("firstChild");
k_lastchild = NewString("lastChild");
}

View file

@ -140,4 +140,4 @@ extern String *k_previoussibling;
extern String *k_nextsibling;
extern String *k_firstchild;
extern String *k_lastchild;
#endif /* SWIG_SWIGKEYS_H_ */
#endif /* SWIG_SWIGKEYS_H_ */

File diff suppressed because it is too large Load diff

View file

@ -21,20 +21,21 @@ char cvsroot_tree_c[] = "$Header$";
* Dump the tag structure of a parse tree to standard output
* ----------------------------------------------------------------------------- */
void
Swig_print_tags(DOH *obj, DOH *root) {
void Swig_print_tags(DOH *obj, DOH *root) {
DOH *croot, *newroot;
DOH *cobj;
if (!root) croot = NewStringEmpty();
else croot = root;
if (!root)
croot = NewStringEmpty();
else
croot = root;
while (obj) {
Printf(stdout,"%s . %s (%s:%d)\n", croot, nodeType(obj), Getfile(obj), Getline(obj));
Printf(stdout, "%s . %s (%s:%d)\n", croot, nodeType(obj), Getfile(obj), Getline(obj));
cobj = firstChild(obj);
if (cobj) {
newroot = NewStringf("%s . %s",croot,nodeType(obj));
Swig_print_tags(cobj,newroot);
newroot = NewStringf("%s . %s", croot, nodeType(obj));
Swig_print_tags(cobj, newroot);
Delete(newroot);
}
obj = nextSibling(obj);
@ -61,36 +62,34 @@ static void print_indent(int l) {
* Swig_print_node(Node *n)
* ----------------------------------------------------------------------------- */
void
Swig_print_node(Node *obj) {
void Swig_print_node(Node *obj) {
Iterator ki;
Node *cobj;
Node *cobj;
print_indent(0);
Printf(stdout,"+++ %s ----------------------------------------\n", nodeType(obj));
Printf(stdout, "+++ %s ----------------------------------------\n", nodeType(obj));
ki = First(obj);
while (ki.key) {
String *k = ki.key;
if ((Cmp(k,"nodeType") == 0) || (Cmp(k,"firstChild") == 0) || (Cmp(k,"lastChild") == 0) ||
(Cmp(k,"parentNode") == 0) || (Cmp(k,"nextSibling") == 0) ||
(Cmp(k,"previousSibling") == 0) || (*(Char(k)) == '$')) {
if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) ||
(Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) {
/* Do nothing */
} else if (Cmp(k,"parms") == 0) {
} else if (Cmp(k, "parms") == 0) {
print_indent(2);
Printf(stdout,"%-12s - %s\n", k, ParmList_protostr(Getattr(obj,k)));
Printf(stdout, "%-12s - %s\n", k, ParmList_protostr(Getattr(obj, k)));
} else {
DOH *o;
char *trunc = "";
print_indent(2);
if (DohIsString(Getattr(obj,k))) {
o = Str(Getattr(obj,k));
if (DohIsString(Getattr(obj, k))) {
o = Str(Getattr(obj, k));
if (Len(o) > 40) {
trunc = "...";
}
Printf(stdout,"%-12s - \"%(escape)-0.40s%s\"\n", k, o, trunc);
Printf(stdout, "%-12s - \"%(escape)-0.40s%s\"\n", k, o, trunc);
Delete(o);
} else {
Printf(stdout,"%-12s - 0x%x\n", k, Getattr(obj,k));
Printf(stdout, "%-12s - 0x%x\n", k, Getattr(obj, k));
}
}
ki = Next(ki);
@ -98,12 +97,12 @@ Swig_print_node(Node *obj) {
cobj = firstChild(obj);
if (cobj) {
indent_level += 6;
Printf(stdout,"\n");
Printf(stdout, "\n");
Swig_print_tree(cobj);
indent_level -= 6;
} else {
print_indent(1);
Printf(stdout,"\n");
Printf(stdout, "\n");
}
}
@ -113,8 +112,7 @@ Swig_print_node(Node *obj) {
* Dump the tree structure of a parse tree to standard output
* ----------------------------------------------------------------------------- */
void
Swig_print_tree(DOH *obj) {
void Swig_print_tree(DOH *obj) {
while (obj) {
Swig_print_node(obj);
obj = nextSibling(obj);
@ -127,25 +125,25 @@ Swig_print_tree(DOH *obj) {
* Appends a new child to a node
* ----------------------------------------------------------------------------- */
void
appendChild(Node *node, Node *chd) {
void appendChild(Node *node, Node *chd) {
Node *lc;
if (!chd) return;
if (!chd)
return;
lc = lastChild(node);
if (!lc) {
set_firstChild(node,chd);
set_firstChild(node, chd);
} else {
set_nextSibling(lc,chd);
set_previousSibling(chd,lc);
set_nextSibling(lc, chd);
set_previousSibling(chd, lc);
}
while (chd) {
lc = chd;
set_parentNode(chd,node);
set_parentNode(chd, node);
chd = nextSibling(chd);
}
set_lastChild(node,lc);
set_lastChild(node, lc);
}
/* -----------------------------------------------------------------------------
@ -154,20 +152,20 @@ appendChild(Node *node, Node *chd) {
* Preppends a new child to a node
* ----------------------------------------------------------------------------- */
void
preppendChild(Node *node, Node *chd) {
void preppendChild(Node *node, Node *chd) {
Node *fc;
if (!chd) return;
if (!chd)
return;
fc = firstChild(node);
if (fc) {
set_nextSibling(chd,fc);
set_previousSibling(fc,chd);
set_nextSibling(chd, fc);
set_previousSibling(fc, chd);
}
set_firstChild(node,chd);
set_firstChild(node, chd);
while (chd) {
set_parentNode(chd,node);
set_parentNode(chd, node);
chd = nextSibling(chd);
}
}
@ -178,8 +176,7 @@ preppendChild(Node *node, Node *chd) {
* Deletes a node.
* ----------------------------------------------------------------------------- */
void
deleteNode(Node *n) {
void deleteNode(Node *n) {
Node *parent;
Node *prev;
Node *next;
@ -188,17 +185,17 @@ deleteNode(Node *n) {
prev = previousSibling(n);
next = nextSibling(n);
if (prev) {
set_nextSibling(prev,next);
set_nextSibling(prev, next);
} else {
if (parent) {
set_firstChild(parent,next);
set_firstChild(parent, next);
}
}
if (next) {
set_previousSibling(next,prev);
set_previousSibling(next, prev);
} else {
if (parent) {
set_lastChild(parent,prev);
set_lastChild(parent, prev);
}
}
}
@ -209,17 +206,16 @@ deleteNode(Node *n) {
* Copies a node, but only copies simple attributes (no lists, hashes).
* ----------------------------------------------------------------------------- */
Node *
copyNode(Node *n) {
Node *copyNode(Node *n) {
Iterator ki;
Node *c = NewHash();
for (ki = First(n); ki.key; ki = Next(ki)) {
if (DohIsString(ki.item)) {
Setattr(c,ki.key,Copy(ki.item));
Setattr(c, ki.key, Copy(ki.item));
}
}
Setfile(c,Getfile(n));
Setline(c,Getline(n));
Setfile(c, Getfile(n));
Setline(c, Getline(n));
return c;
}
@ -230,11 +226,10 @@ copyNode(Node *n) {
* subtypes with extra information.
* ----------------------------------------------------------------------------- */
void
Swig_tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
void Swig_tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
while (n) {
Setattr(n,attrname,value);
Swig_tag_nodes(firstChild(n),attrname, value);
Setattr(n, attrname, value);
Swig_tag_nodes(firstChild(n), attrname, value);
n = nextSibling(n);
}
}
@ -243,10 +238,9 @@ Swig_tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
* checkAttribute()
* ----------------------------------------------------------------------------- */
int
checkAttribute(Node *n, const String_or_char *name, const String_or_char *value) {
String *v = Getattr(n,name);
return v ? Equal(v,value) : 0;
int checkAttribute(Node *n, const String_or_char *name, const String_or_char *value) {
String *v = Getattr(n, name);
return v ? Equal(v, value) : 0;
}
/* -----------------------------------------------------------------------------
@ -263,8 +257,7 @@ checkAttribute(Node *n, const String_or_char *name, const String_or_char *value)
* This function can be called more than once with different namespaces.
* ----------------------------------------------------------------------------- */
int
Swig_require(const char *ns, Node *n, ...) {
int Swig_require(const char *ns, Node *n, ...) {
va_list ap;
char *name;
DOH *obj;
@ -282,13 +275,13 @@ Swig_require(const char *ns, Node *n, ...) {
opt = 1;
name++;
}
obj = Getattr(n,name);
obj = Getattr(n, name);
if (!opt && !obj) {
Printf(stderr,"%s:%d. Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n",
Getfile(n), Getline(n), name, nodeType(n));
Printf(stderr, "%s:%d. Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n", Getfile(n), Getline(n), name, nodeType(n));
assert(obj);
}
if (!obj) obj = DohNone;
if (!obj)
obj = DohNone;
if (newref) {
/* Save a copy of the attribute */
Setattr(n, NewStringf("%s:%s", ns, name), obj);
@ -299,14 +292,14 @@ Swig_require(const char *ns, Node *n, ...) {
/* Save the view */
{
String *view = Getattr(n,k_view);
String *view = Getattr(n, k_view);
if (view) {
if (Strcmp(view,ns) != 0) {
if (Strcmp(view, ns) != 0) {
Setattr(n, NewStringf("%s:view", ns), view);
Setattr(n,k_view,ns);
Setattr(n, k_view, ns);
}
} else {
Setattr(n,k_view,ns);
Setattr(n, k_view, ns);
}
}
@ -320,8 +313,7 @@ Swig_require(const char *ns, Node *n, ...) {
* are saved, ie behaves as if all the attribute names were prefixed by ?.
* ----------------------------------------------------------------------------- */
int
Swig_save(const char *ns, Node *n, ...) {
int Swig_save(const char *ns, Node *n, ...) {
va_list ap;
char *name;
DOH *obj;
@ -334,12 +326,13 @@ Swig_save(const char *ns, Node *n, ...) {
} else if (*name == '?') {
name++;
}
obj = Getattr(n,name);
if (!obj) obj = DohNone;
obj = Getattr(n, name);
if (!obj)
obj = DohNone;
/* Save a copy of the attribute */
if (Setattr(n, NewStringf("%s:%s", ns, name), obj)) {
Printf(stderr,"Swig_save('%s','%s'): Warning, attribute '%s' was already saved.\n", ns, nodeType(n), name);
Printf(stderr, "Swig_save('%s','%s'): Warning, attribute '%s' was already saved.\n", ns, nodeType(n), name);
}
name = va_arg(ap, char *);
}
@ -347,14 +340,14 @@ Swig_save(const char *ns, Node *n, ...) {
/* Save the view */
{
String *view = Getattr(n,k_view);
String *view = Getattr(n, k_view);
if (view) {
if (Strcmp(view,ns) != 0) {
if (Strcmp(view, ns) != 0) {
Setattr(n, NewStringf("%s:view", ns), view);
Setattr(n,k_view,ns);
Setattr(n, k_view, ns);
}
} else {
Setattr(n,k_view,ns);
Setattr(n, k_view, ns);
}
}
@ -366,15 +359,14 @@ Swig_save(const char *ns, Node *n, ...) {
* Restores attributes saved by a previous call to Swig_require() or Swig_save().
* ----------------------------------------------------------------------------- */
void
Swig_restore(Node *n) {
void Swig_restore(Node *n) {
String *temp;
int len;
List *l;
int len;
List *l;
String *ns;
Iterator ki;
ns = Getattr(n,k_view);
ns = Getattr(n, k_view);
assert(ns);
l = NewList();
@ -384,16 +376,14 @@ Swig_restore(Node *n) {
for (ki = First(n); ki.key; ki = Next(ki)) {
if (Strncmp(temp, ki.key, len) == 0) {
Append(l,ki.key);
Append(l, ki.key);
}
}
for (ki = First(l); ki.item; ki = Next(ki)) {
DOH *obj = Getattr(n,ki.item);
Setattr(n,Char(ki.item)+len,obj);
Delattr(n,ki.item);
DOH *obj = Getattr(n, ki.item);
Setattr(n, Char(ki.item) + len, obj);
Delattr(n, ki.item);
}
Delete(l);
Delete(temp);
}

File diff suppressed because it is too large Load diff

View file

@ -111,8 +111,7 @@ char cvsroot_typeobj_c[] = "$Header$";
* ----------------------------------------------------------------------------- */
#ifdef NEW
SwigType *
NewSwigType(const String_or_char *initial) {
SwigType *NewSwigType(const String_or_char *initial) {
return NewString(initial);
}
@ -132,8 +131,7 @@ NewSwigType(const String_or_char *initial) {
* substring, to chop the element off, or for other purposes).
* ----------------------------------------------------------------------------- */
static int
element_size(char *c) {
static int element_size(char *c) {
int nparen;
char *s = c;
while (*c) {
@ -144,15 +142,18 @@ element_size(char *c) {
nparen = 1;
c++;
while (*c) {
if (*c == '(') nparen++;
if (*c == '(')
nparen++;
if (*c == ')') {
nparen--;
if (nparen == 0) break;
if (nparen == 0)
break;
}
c++;
}
}
if (*c) c++;
if (*c)
c++;
}
return (int) (c - s);
}
@ -163,10 +164,9 @@ element_size(char *c) {
* Deletes one type element from the type.
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_del_element(SwigType *t) {
SwigType *SwigType_del_element(SwigType *t) {
int sz = element_size(Char(t));
Delslice(t,0,sz);
Delslice(t, 0, sz);
return t;
}
@ -176,21 +176,21 @@ SwigType_del_element(SwigType *t) {
* Pop one type element off the type.
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_pop(SwigType *t) {
SwigType *result;
char *c;
int sz;
SwigType *SwigType_pop(SwigType *t) {
SwigType *result;
char *c;
int sz;
c = Char(t);
if (!*c) return 0;
if (!*c)
return 0;
sz = element_size(c);
result = NewStringWithSize(c,sz);
Delslice(t,0,sz);
result = NewStringWithSize(c, sz);
Delslice(t, 0, sz);
c = Char(t);
if (*c == '.') {
Delitem(t,0);
Delitem(t, 0);
}
return result;
}
@ -201,26 +201,28 @@ SwigType_pop(SwigType *t) {
* Returns the parameter of an operator as a string
* ----------------------------------------------------------------------------- */
String *
SwigType_parm(SwigType *t) {
String *SwigType_parm(SwigType *t) {
char *start, *c;
int nparens = 0;
int nparens = 0;
c = Char(t);
while (*c && (*c != '(') && (*c != '.')) c++;
if (!*c || (*c == '.')) return 0;
while (*c && (*c != '(') && (*c != '.'))
c++;
if (!*c || (*c == '.'))
return 0;
c++;
start = c;
while (*c) {
if (*c == ')') {
if (nparens == 0) break;
if (nparens == 0)
break;
nparens--;
} else if (*c == '(') {
nparens++;
}
c++;
}
return NewStringWithSize(start, (int) (c-start));
return NewStringWithSize(start, (int) (c - start));
}
/* -----------------------------------------------------------------------------
@ -230,20 +232,21 @@ SwigType_parm(SwigType *t) {
* ----------------------------------------------------------------------------- */
List *SwigType_split(const SwigType *t) {
DOH *item;
List *list;
char *c;
int len;
DOH *item;
List *list;
char *c;
int len;
c = Char(t);
list = NewList();
while (*c) {
len = element_size(c);
item = NewStringWithSize(c,len);
Append(list,item);
item = NewStringWithSize(c, len);
Append(list, item);
Delete(item);
c = c + len;
if (*c == '.') c++;
if (*c == '.')
c++;
}
return list;
}
@ -255,40 +258,45 @@ List *SwigType_split(const SwigType *t) {
* ----------------------------------------------------------------------------- */
List *SwigType_parmlist(const String *p) {
DOH *item;
DOH *item;
List *list;
char *c, *itemstart;
c = Char(p);
while (*c && (*c != '(') && (*c != '.')) c++;
if (!*c || (*c == '.')) return 0;
while (*c && (*c != '(') && (*c != '.'))
c++;
if (!*c || (*c == '.'))
return 0;
c++;
list = NewList();
itemstart = c;
while (*c) {
if (*c == ',') {
item = NewStringWithSize(itemstart, (int) (c - itemstart));
Append(list,item);
Append(list, item);
Delete(item);
itemstart = c+1;
itemstart = c + 1;
} else if (*c == '(') {
int nparens = 1;
c++;
while (*c) {
if (*c == '(') nparens++;
if (*c == '(')
nparens++;
if (*c == ')') {
nparens--;
if (nparens == 0) break;
if (nparens == 0)
break;
}
c++;
}
} else if (*c == ')') {
break;
}
if (*c) c++;
if (*c)
c++;
}
item = NewStringWithSize(itemstart,(int) (c - itemstart));
Append(list,item);
item = NewStringWithSize(itemstart, (int) (c - itemstart));
Append(list, item);
Delete(item);
return list;
}
@ -304,43 +312,42 @@ List *SwigType_parmlist(const String *p) {
* functions take into account qualifiers (if any).
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_add_pointer(SwigType *t) {
Insert(t,0,"p.");
SwigType *SwigType_add_pointer(SwigType *t) {
Insert(t, 0, "p.");
return t;
}
SwigType *
SwigType_del_pointer(SwigType *t) {
SwigType *SwigType_del_pointer(SwigType *t) {
char *c, *s;
c = Char(t);
s = c;
/* Skip qualifiers, if any */
if (strncmp(c,"q(",2) == 0) {
c = strchr(c,'.');
if (strncmp(c, "q(", 2) == 0) {
c = strchr(c, '.');
assert(c);
c++;
}
if (strncmp(c,"p.",2)) {
if (strncmp(c, "p.", 2)) {
printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n");
abort();
}
Delslice(t,0,(c-s)+2);
Delslice(t, 0, (c - s) + 2);
return t;
}
int
SwigType_ispointer(SwigType *t) {
int SwigType_ispointer(SwigType *t) {
char *c;
if (!t) return 0;
if (!t)
return 0;
c = Char(t);
/* Skip qualifiers, if any */
if (strncmp(c,"q(",2) == 0) {
c = strchr(c,'.');
if (!c) return 0;
if (strncmp(c, "q(", 2) == 0) {
c = strchr(c, '.');
if (!c)
return 0;
c++;
}
if (strncmp(c,"p.",2) == 0) {
if (strncmp(c, "p.", 2) == 0) {
return 1;
}
return 0;
@ -357,29 +364,27 @@ SwigType_ispointer(SwigType *t) {
* functions take into account qualifiers (if any).
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_add_reference(SwigType *t) {
Insert(t,0,"r.");
return t;
}
SwigType *
SwigType_del_reference(SwigType *t) {
char *c = Char(t);
int check = strncmp(c,"r.",2);
assert(check == 0);
Delslice(t,0,2);
SwigType *SwigType_add_reference(SwigType *t) {
Insert(t, 0, "r.");
return t;
}
int
SwigType_isreference(SwigType *t) {
SwigType *SwigType_del_reference(SwigType *t) {
char *c = Char(t);
int check = strncmp(c, "r.", 2);
assert(check == 0);
Delslice(t, 0, 2);
return t;
}
int SwigType_isreference(SwigType *t) {
char *c;
if (!t) return 0;
if (!t)
return 0;
c = Char(t);
if (strncmp(c,"r.",2) == 0) {
if (strncmp(c, "r.", 2) == 0) {
return 1;
}
}
return 0;
}
@ -397,20 +402,19 @@ SwigType_isreference(SwigType *t) {
* stored in exactly the same way as "q(const volatile)".
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
char temp[256], newq[256];
int sz, added = 0;
int sz, added = 0;
char *q, *cqual;
char *c = Char(t);
cqual = Char(qual);
if (!(strncmp(c,"q(",2) == 0)) {
sprintf(temp,"q(%s).",cqual);
Insert(t,0,temp);
if (!(strncmp(c, "q(", 2) == 0)) {
sprintf(temp, "q(%s).", cqual);
Insert(t, 0, temp);
return t;
}
}
/* The type already has a qualifier on it. In this case, we first check to
see if the qualifier is already specified. In that case do nothing.
@ -418,58 +422,57 @@ SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
order */
sz = element_size(c);
strncpy(temp,c, (sz < 256) ? sz : 256);
strncpy(temp, c, (sz < 256) ? sz : 256);
if (strstr(temp,cqual)) {
if (strstr(temp, cqual)) {
/* Qualifier already added */
return t;
}
/* Add the qualifier to the existing list. */
strcpy(newq,"q(");
q = temp+2;
q = strtok(q," ).");
strcpy(newq, "q(");
q = temp + 2;
q = strtok(q, " ).");
while (q) {
if (strcmp(cqual,q) < 0) {
if (strcmp(cqual, q) < 0) {
/* New qualifier is less that current qualifier. We need to insert it */
strcat(newq,cqual);
strcat(newq," ");
strcat(newq,q);
strcat(newq, cqual);
strcat(newq, " ");
strcat(newq, q);
added = 1;
} else {
strcat(newq,q);
strcat(newq, q);
}
q = strtok(NULL," ).");
q = strtok(NULL, " ).");
if (q) {
strcat(newq," ");
strcat(newq, " ");
}
}
if (!added) {
strcat(newq," ");
strcat(newq,cqual);
strcat(newq, " ");
strcat(newq, cqual);
}
strcat(newq,").");
Delslice(t,0,sz);
Insert(t,0,newq);
strcat(newq, ").");
Delslice(t, 0, sz);
Insert(t, 0, newq);
return t;
}
SwigType *
SwigType_del_qualifier(SwigType *t) {
SwigType *SwigType_del_qualifier(SwigType *t) {
char *c = Char(t);
int check = strncmp(c,"q(",2);
int check = strncmp(c, "q(", 2);
assert(check == 0);
Delslice(t,0,element_size(c));
Delslice(t, 0, element_size(c));
return t;
}
int
SwigType_isqualifier(SwigType *t) {
int SwigType_isqualifier(SwigType *t) {
char *c;
if (!t) return 0;
if (!t)
return 0;
c = Char(t);
if (strncmp(c,"q(",2) == 0) {
if (strncmp(c, "q(", 2) == 0) {
return 1;
}
return 0;
@ -485,29 +488,27 @@ SwigType_isqualifier(SwigType *t) {
* Add, remove, and test for C++ pointer to members.
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_add_memberpointer(SwigType *t, const String_or_char *name) {
SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *name) {
String *temp = NewStringf("m(%s).", name);
Insert(t,0,temp);
Insert(t, 0, temp);
Delete(temp);
return t;
}
SwigType *
SwigType_del_memberpointer(SwigType *t) {
SwigType *SwigType_del_memberpointer(SwigType *t) {
char *c = Char(t);
int check = strncmp(c,"m(",2);
int check = strncmp(c, "m(", 2);
assert(check == 0);
Delslice(t,0,element_size(c));
Delslice(t, 0, element_size(c));
return t;
}
int
SwigType_ismemberpointer(SwigType *t) {
int SwigType_ismemberpointer(SwigType *t) {
char *c;
if (!t) return 0;
if (!t)
return 0;
c = Char(t);
if (strncmp(c,"m(",2) == 0) {
if (strncmp(c, "m(", 2) == 0) {
return 1;
}
return 0;
@ -529,57 +530,54 @@ SwigType_ismemberpointer(SwigType *t) {
* SwigType_pop_arrays() - Remove all arrays
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_add_array(SwigType *t, const String_or_char *size) {
SwigType *SwigType_add_array(SwigType *t, const String_or_char *size) {
char temp[512];
strcpy(temp,"a(");
strcat(temp,Char(size));
strcat(temp,").");
Insert(t,0,temp);
strcpy(temp, "a(");
strcat(temp, Char(size));
strcat(temp, ").");
Insert(t, 0, temp);
return t;
}
SwigType *
SwigType_del_array(SwigType *t) {
SwigType *SwigType_del_array(SwigType *t) {
char *c = Char(t);
int check = strncmp(c,"a(",2);
int check = strncmp(c, "a(", 2);
assert(check == 0);
Delslice(t,0,element_size(c));
Delslice(t, 0, element_size(c));
return t;
}
int SwigType_isarray(SwigType *t) {
char *c;
if (!t) return 0;
if (!t)
return 0;
c = Char(t);
if (strncmp(c,"a(",2) == 0) {
if (strncmp(c, "a(", 2) == 0) {
return 1;
}
return 0;
}
/* Remove all arrays */
SwigType *
SwigType_pop_arrays(SwigType *t) {
SwigType *SwigType_pop_arrays(SwigType *t) {
String *ta;
assert(SwigType_isarray(t));
ta = NewStringEmpty();
while (SwigType_isarray(t)) {
SwigType *td = SwigType_pop(t);
Append(ta,td);
Append(ta, td);
Delete(td);
}
return ta;
}
/* Return number of array dimensions */
int
SwigType_array_ndim(SwigType *t) {
int SwigType_array_ndim(SwigType *t) {
int ndim = 0;
char *c = Char(t);
while (c && (strncmp(c,"a(",2) == 0)) {
c = strchr(c,'.');
while (c && (strncmp(c, "a(", 2) == 0)) {
c = strchr(c, '.');
c++;
ndim++;
}
@ -587,25 +585,24 @@ SwigType_array_ndim(SwigType *t) {
}
/* Get nth array dimension */
String *
SwigType_array_getdim(SwigType *t, int n) {
String *SwigType_array_getdim(SwigType *t, int n) {
char *c = Char(t);
while (c && (strncmp(c,"a(",2) == 0) && (n > 0)) {
c = strchr(c,'.');
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
c = strchr(c, '.');
c++;
n--;
}
if (n == 0) {
String *dim = SwigType_parm(c);
String *dim = SwigType_parm(c);
if (SwigType_istemplate(dim)) {
String *ndim = SwigType_namestr(dim);
Delete(dim);
dim = ndim;
}
return dim;
}
return 0;
}
@ -617,10 +614,11 @@ void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep) {
char *c = Char(t);
start = c;
if (strncmp(c,"a(",2)) abort();
if (strncmp(c, "a(", 2))
abort();
while (c && (strncmp(c,"a(",2) == 0) && (n > 0)) {
c = strchr(c,'.');
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
c = strchr(c, '.');
c++;
n--;
}
@ -628,19 +626,18 @@ void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep) {
temp = *c;
*c = 0;
result = NewString(start);
Printf(result,"a(%s)",rep);
Printf(result, "a(%s)", rep);
*c = temp;
c = strchr(c,'.');
Append(result,c);
c = strchr(c, '.');
Append(result, c);
}
Clear(t);
Append(t,result);
Append(t, result);
Delete(result);
}
/* Return base type of an array */
SwigType *
SwigType_array_type(SwigType *ty) {
SwigType *SwigType_array_type(SwigType *ty) {
SwigType *t;
t = Copy(ty);
while (SwigType_isarray(t)) {
@ -662,72 +659,73 @@ SwigType_array_type(SwigType *ty) {
* ----------------------------------------------------------------------------- */
/* Returns the function type, t, constructed from the parameters, parms */
SwigType *
SwigType_add_function(SwigType *t, ParmList *parms) {
SwigType *SwigType_add_function(SwigType *t, ParmList *parms) {
String *pstr;
Parm *p;
Parm *p;
Insert(t,0,").");
Insert(t, 0, ").");
pstr = NewString("f(");
p = parms;
for (p = parms; p; p = nextSibling(p)) {
if (p != parms) Putc(',',pstr);
Append(pstr, Getattr(p,k_type));
if (p != parms)
Putc(',', pstr);
Append(pstr, Getattr(p, k_type));
}
Insert(t,0,pstr);
Insert(t, 0, pstr);
Delete(pstr);
return t;
}
SwigType *
SwigType_pop_function(SwigType *t) {
SwigType *SwigType_pop_function(SwigType *t) {
SwigType *f = 0;
SwigType *g = 0;
char *c = Char(t);
if (strncmp(c,"q(",2) == 0) {
if (strncmp(c, "q(", 2) == 0) {
f = SwigType_pop(t);
c = Char(t);
}
if (strncmp(c,"f(",2)) {
if (strncmp(c, "f(", 2)) {
printf("Fatal error. SwigType_pop_function applied to non-function.\n");
abort();
}
g = SwigType_pop(t);
if (f) SwigType_push(g,f);
if (f)
SwigType_push(g, f);
Delete(f);
return g;
}
int
SwigType_isfunction(SwigType *t) {
int SwigType_isfunction(SwigType *t) {
char *c;
if (!t) {
return 0;
}
c = Char(t);
if (strncmp(c,"q(",2) == 0) {
if (strncmp(c, "q(", 2) == 0) {
/* Might be a 'const' function. Try to skip over the 'const' */
c = strchr(c,'.');
if (c) c++;
else return 0;
c = strchr(c, '.');
if (c)
c++;
else
return 0;
}
if (strncmp(c,"f(",2) == 0) {
if (strncmp(c, "f(", 2) == 0) {
return 1;
}
return 0;
}
ParmList *
SwigType_function_parms(SwigType *t) {
ParmList *SwigType_function_parms(SwigType *t) {
List *l = SwigType_parmlist(t);
Hash *p, *pp = 0, *firstp = 0;
Iterator o;
for (o = First(l); o.item; o = Next(o)) {
p = NewParm(o.item,0);
if (!firstp) firstp = p;
p = NewParm(o.item, 0);
if (!firstp)
firstp = p;
if (pp) {
set_nextSibling(pp,p);
set_nextSibling(pp, p);
Delete(p);
}
pp = p;
@ -737,7 +735,8 @@ SwigType_function_parms(SwigType *t) {
}
int SwigType_isvarargs(const SwigType *t) {
if (Strcmp(t,"v(...)") == 0) return 1;
if (Strcmp(t, "v(...)") == 0)
return 1;
return 0;
}
@ -758,24 +757,25 @@ int SwigType_isvarargs(const SwigType *t) {
* vector<int *> ----> "vector<(p.int)>"
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_add_template(SwigType *t, ParmList *parms) {
Parm *p;
SwigType *SwigType_add_template(SwigType *t, ParmList *parms) {
Parm *p;
Append(t,"<(");
Append(t, "<(");
p = parms;
for (p = parms; p; p = nextSibling(p)) {
String *v;
if (Getattr(p,k_default)) continue;
if (p != parms) Append(t,",");
v = Getattr(p,k_value);
if (Getattr(p, k_default))
continue;
if (p != parms)
Append(t, ",");
v = Getattr(p, k_value);
if (v) {
Append(t,v);
Append(t, v);
} else {
Append(t,Getattr(p,k_type));
Append(t, Getattr(p, k_type));
}
}
Append(t,")>");
Append(t, ")>");
return t;
}
@ -791,11 +791,10 @@ SwigType_add_template(SwigType *t, ParmList *parms) {
* Results in "Foo"
* ----------------------------------------------------------------------------- */
String *
SwigType_templateprefix(const SwigType *t) {
String *SwigType_templateprefix(const SwigType *t) {
const char *s = Char(t);
const char *c = strstr(s,"<(");
return c ? NewStringWithSize(s, c-s) : NewString(s);
const char *c = strstr(s, "<(");
return c ? NewStringWithSize(s, c - s) : NewString(s);
}
/* -----------------------------------------------------------------------------
@ -809,17 +808,18 @@ SwigType_templateprefix(const SwigType *t) {
* returns "::bar"
* ----------------------------------------------------------------------------- */
String *
SwigType_templatesuffix(const SwigType *t) {
String *SwigType_templatesuffix(const SwigType *t) {
const char *c;
c = Char(t);
while (*c) {
if ((*c == '<') && (*(c+1) == '(')) {
if ((*c == '<') && (*(c + 1) == '(')) {
int nest = 1;
c++;
while (*c && nest) {
if (*c == '<') nest++;
if (*c == '>') nest--;
if (*c == '<')
nest++;
if (*c == '>')
nest--;
c++;
}
return NewString(c);
@ -835,22 +835,23 @@ SwigType_templatesuffix(const SwigType *t) {
* Returns the template part
* ----------------------------------------------------------------------------- */
String *
SwigType_templateargs(const SwigType *t) {
String *SwigType_templateargs(const SwigType *t) {
const char *c;
const char *start;
c = Char(t);
while (*c) {
if ((*c == '<') && (*(c+1) == '(')) {
if ((*c == '<') && (*(c + 1) == '(')) {
int nest = 1;
start = c;
c++;
while (*c && nest) {
if (*c == '<') nest++;
if (*c == '>') nest--;
if (*c == '<')
nest++;
if (*c == '>')
nest--;
c++;
}
return NewStringWithSize(start,c-start);
return NewStringWithSize(start, c - start);
}
c++;
}
@ -863,10 +864,10 @@ SwigType_templateargs(const SwigType *t) {
* Tests a type to see if it includes template parameters
* ----------------------------------------------------------------------------- */
int
SwigType_istemplate(const SwigType *t) {
int SwigType_istemplate(const SwigType *t) {
char *ct = Char(t);
if ((ct = strstr(ct,"<(")) && (strstr(ct + 2,")>"))) return 1;
if ((ct = strstr(ct, "<(")) && (strstr(ct + 2, ")>")))
return 1;
return 0;
}
@ -877,8 +878,7 @@ SwigType_istemplate(const SwigType *t) {
* type "p.p.int", the function would return "int".
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_base(const SwigType *t) {
SwigType *SwigType_base(const SwigType *t) {
char *c;
char *lastop = 0;
c = Char(t);
@ -888,8 +888,8 @@ SwigType_base(const SwigType *t) {
/* Search for the last type constructor separator '.' */
while (*c) {
if (*c == '.') {
if (*(c+1)) {
lastop = c+1;
if (*(c + 1)) {
lastop = c + 1;
}
c++;
continue;
@ -899,11 +899,14 @@ SwigType_base(const SwigType *t) {
int ntemp = 1;
c++;
while ((*c) && (ntemp > 0)) {
if (*c == '>') ntemp--;
else if (*c == '<') ntemp++;
if (*c == '>')
ntemp--;
else if (*c == '<')
ntemp++;
c++;
}
if (ntemp) break;
if (ntemp)
break;
continue;
}
if (*c == '(') {
@ -911,11 +914,14 @@ SwigType_base(const SwigType *t) {
int nparen = 1;
c++;
while ((*c) && (nparen > 0)) {
if (*c == '(') nparen++;
else if (*c == ')') nparen--;
if (*c == '(')
nparen++;
else if (*c == ')')
nparen--;
c++;
}
if (nparen) break;
if (nparen)
break;
continue;
}
c++;
@ -930,8 +936,7 @@ SwigType_base(const SwigType *t) {
* type "p.p.int" is "p.p.".
* ----------------------------------------------------------------------------- */
String *
SwigType_prefix(const SwigType *t) {
String *SwigType_prefix(const SwigType *t) {
char *c, *d;
String *r = 0;
@ -939,7 +944,8 @@ SwigType_prefix(const SwigType *t) {
d = c + strlen(c);
/* Check for a type constructor */
if ((d > c) && (*(d-1) == '.')) d--;
if ((d > c) && (*(d - 1) == '.'))
d--;
while (d > c) {
d--;
@ -947,8 +953,10 @@ SwigType_prefix(const SwigType *t) {
int nest = 1;
d--;
while ((d > c) && (nest)) {
if (*d == '>') nest++;
if (*d == '<') nest--;
if (*d == '>')
nest++;
if (*d == '<')
nest--;
d--;
}
}
@ -957,17 +965,19 @@ SwigType_prefix(const SwigType *t) {
int nparen = 1;
d--;
while ((d > c) && (nparen)) {
if (*d == ')') nparen++;
if (*d == '(') nparen--;
if (*d == ')')
nparen++;
if (*d == '(')
nparen--;
d--;
}
}
if (*d == '.') {
char t = *(d+1);
*(d+1) = 0;
char t = *(d + 1);
*(d + 1) = 0;
r = NewString(c);
*(d+1) = t;
*(d + 1) = t;
return r;
}
}
@ -980,34 +990,34 @@ SwigType_prefix(const SwigType *t) {
* Strip all qualifiers from a type and return a new type
* ----------------------------------------------------------------------------- */
SwigType *
SwigType_strip_qualifiers(SwigType *t) {
SwigType *SwigType_strip_qualifiers(SwigType *t) {
static Hash *memoize_stripped = 0;
SwigType *r;
List *l;
Iterator ei;
List *l;
Iterator ei;
if (!memoize_stripped)
memoize_stripped = NewHash();
r = Getattr(memoize_stripped, t);
if (r)
return Copy(r);
if (!memoize_stripped) memoize_stripped = NewHash();
r = Getattr(memoize_stripped,t);
if (r) return Copy(r);
l = SwigType_split(t);
r = NewStringEmpty();
for (ei = First(l);ei.item; ei = Next(ei)) {
if (SwigType_isqualifier(ei.item)) continue;
Append(r,ei.item);
for (ei = First(l); ei.item; ei = Next(ei)) {
if (SwigType_isqualifier(ei.item))
continue;
Append(r, ei.item);
}
Delete(l);
{
String *key, *value;
key = Copy(t);
value = Copy(r);
Setattr(memoize_stripped,key,value);
Setattr(memoize_stripped, key, value);
Delete(key);
Delete(value);
}
return r;
}

File diff suppressed because it is too large Load diff

View file

@ -20,21 +20,15 @@ static Hash *warnings = 0;
* Issue a warning
* ----------------------------------------------------------------------------- */
void
Swig_warn(const char *filename, int line, const char *msg) {
void Swig_warn(const char *filename, int line, const char *msg) {
String *key;
if (!warnings) {
warnings = NewHash();
}
key = NewStringf("%s:%d", filename,line);
if (!Getattr(warnings,key)) {
Printf(stderr,"swig-dev warning:%s:%d:%s\n", filename, line, msg);
Setattr(warnings,key,key);
key = NewStringf("%s:%d", filename, line);
if (!Getattr(warnings, key)) {
Printf(stderr, "swig-dev warning:%s:%d:%s\n", filename, line, msg);
Setattr(warnings, key, key);
}
Delete(key);
}

View file

@ -14,7 +14,7 @@ char cvsroot_wrapfunc_c[] = "$Header$";
#include "swig.h"
#include <ctype.h>
static int Compact_mode = 0; /* set to 0 on default */
static int Compact_mode = 0; /* set to 0 on default */
static int Max_line_size = 128;
/* -----------------------------------------------------------------------------
@ -23,8 +23,7 @@ static int Max_line_size = 128;
* Create a new wrapper function object.
* ----------------------------------------------------------------------------- */
Wrapper *
NewWrapper() {
Wrapper *NewWrapper() {
Wrapper *w;
w = (Wrapper *) malloc(sizeof(Wrapper));
w->localh = NewHash();
@ -40,8 +39,7 @@ NewWrapper() {
* Delete a wrapper function object.
* ----------------------------------------------------------------------------- */
void
DelWrapper(Wrapper *w) {
void DelWrapper(Wrapper *w) {
Delete(w->localh);
Delete(w->locals);
Delete(w->code);
@ -55,8 +53,7 @@ DelWrapper(Wrapper *w) {
* Set compact_mode.
* ----------------------------------------------------------------------------- */
void
Wrapper_compact_print_mode_set(int flag) {
void Wrapper_compact_print_mode_set(int flag) {
Compact_mode = flag;
}
@ -66,8 +63,7 @@ Wrapper_compact_print_mode_set(int flag) {
* Formats a wrapper function and fixes up the indentation.
* ----------------------------------------------------------------------------- */
void
Wrapper_pretty_print(String *str, File *f) {
void Wrapper_pretty_print(String *str, File *f) {
String *ts;
int level = 0;
int c, i;
@ -77,127 +73,132 @@ Wrapper_pretty_print(String *str, File *f) {
int label = 0;
ts = NewStringEmpty();
Seek(str,0, SEEK_SET);
Seek(str, 0, SEEK_SET);
while ((c = Getc(str)) != EOF) {
if (c == '\"') {
Putc(c,ts);
Putc(c, ts);
while ((c = Getc(str)) != EOF) {
if (c == '\\') {
Putc(c,ts);
Putc(c, ts);
c = Getc(str);
}
Putc(c,ts);
if (c == '\"') break;
Putc(c, ts);
if (c == '\"')
break;
}
empty = 0;
} else if (c == '\'') {
Putc(c,ts);
Putc(c, ts);
while ((c = Getc(str)) != EOF) {
if (c == '\\') {
Putc(c,ts);
Putc(c, ts);
c = Getc(str);
}
Putc(c,ts);
if (c == '\'') break;
Putc(c, ts);
if (c == '\'')
break;
}
empty = 0;
} else if (c == ':') {
Putc(c,ts);
Putc(c, ts);
if ((c = Getc(str)) == '\n') {
if (!empty && !strchr(Char(ts),'?')) label = 1;
if (!empty && !strchr(Char(ts), '?'))
label = 1;
}
Ungetc(c,str);
Ungetc(c, str);
} else if (c == '(') {
Putc(c,ts);
plevel+=indent;
Putc(c, ts);
plevel += indent;
empty = 0;
} else if (c == ')') {
Putc(c,ts);
plevel-=indent;
Putc(c, ts);
plevel -= indent;
empty = 0;
} else if (c == '{') {
Putc(c,ts);
Putc('\n',ts);
for (i = 0; i < level; i++)
Putc(' ',f);
Printf(f,"%s", ts);
Putc(c, ts);
Putc('\n', ts);
for (i = 0; i < level; i++)
Putc(' ', f);
Printf(f, "%s", ts);
Clear(ts);
level+=indent;
level += indent;
while ((c = Getc(str)) != EOF) {
if (!isspace(c)) {
Ungetc(c,str);
Ungetc(c, str);
break;
}
}
empty = 0;
} else if (c == '}') {
if (!empty) {
Putc('\n',ts);
Putc('\n', ts);
for (i = 0; i < level; i++)
Putc(' ',f);
Printf(f,"%s",ts);
Putc(' ', f);
Printf(f, "%s", ts);
Clear(ts);
}
level-=indent;
Putc(c,ts);
level -= indent;
Putc(c, ts);
empty = 0;
} else if (c == '\n') {
Putc(c,ts);
Putc(c, ts);
empty = 0;
if (!empty) {
int slevel = level;
if (label && (slevel >= indent)) slevel -= indent;
if (label && (slevel >= indent))
slevel -= indent;
if ((Char(ts))[0] != '#') {
for (i = 0; i < slevel; i++)
Putc(' ',f);
Putc(' ', f);
}
Printf(f,"%s",ts);
Printf(f, "%s", ts);
for (i = 0; i < plevel; i++)
Putc(' ',f);
Putc(' ', f);
}
Clear(ts);
label = 0;
empty = 1;
} else if (c == '/') {
empty = 0;
Putc(c,ts);
Putc(c, ts);
c = Getc(str);
if (c != EOF) {
Putc(c,ts);
if (c == '/') { /* C++ comment */
Putc(c, ts);
if (c == '/') { /* C++ comment */
while ((c = Getc(str)) != EOF) {
if (c == '\n') {
Ungetc(c,str);
Ungetc(c, str);
break;
}
Putc(c,ts);
Putc(c, ts);
}
} else if (c == '*') { /* C comment */
int endstar = 0;
} else if (c == '*') { /* C comment */
int endstar = 0;
while ((c = Getc(str)) != EOF) {
if (endstar && c == '/') { /* end of C comment */
Putc(c,ts);
if (endstar && c == '/') { /* end of C comment */
Putc(c, ts);
break;
}
endstar = (c == '*');
Putc(c,ts);
if (c == '\n') { /* multi-line C comment. Could be improved slightly. */
for (i = 0; i < level; i++)
Putc(' ',ts);
}
endstar = (c == '*');
Putc(c, ts);
if (c == '\n') { /* multi-line C comment. Could be improved slightly. */
for (i = 0; i < level; i++)
Putc(' ', ts);
}
}
}
}
}
} else {
if (!empty || !isspace(c)) {
Putc(c,ts);
Putc(c, ts);
empty = 0;
}
}
}
if (!empty) Printf(f,"%s",ts);
if (!empty)
Printf(f, "%s", ts);
Delete(ts);
Printf(f,"\n");
Printf(f, "\n");
}
/* -----------------------------------------------------------------------------
@ -207,9 +208,8 @@ Wrapper_pretty_print(String *str, File *f) {
* Print out in compact format, with Compact enabled.
* ----------------------------------------------------------------------------- */
void
Wrapper_compact_print(String *str, File *f) {
String *ts, *tf; /*temp string & temp file */
void Wrapper_compact_print(String *str, File *f) {
String *ts, *tf; /*temp string & temp file */
int level = 0;
int c, i;
int empty = 1;
@ -217,163 +217,165 @@ Wrapper_compact_print(String *str, File *f) {
ts = NewStringEmpty();
tf = NewStringEmpty();
Seek(str,0, SEEK_SET);
Seek(str, 0, SEEK_SET);
while ((c = Getc(str)) != EOF) {
if (c == '\"') { /* string 1 */
if (c == '\"') { /* string 1 */
empty = 0;
Putc(c,ts);
Putc(c, ts);
while ((c = Getc(str)) != EOF) {
if (c == '\\') {
Putc(c,ts);
Putc(c, ts);
c = Getc(str);
}
Putc(c,ts);
if (c == '\"') break;
Putc(c, ts);
if (c == '\"')
break;
}
} else if (c == '\'') { /* string 2 */
} else if (c == '\'') { /* string 2 */
empty = 0;
Putc(c,ts);
Putc(c, ts);
while ((c = Getc(str)) != EOF) {
if (c == '\\') {
Putc(c,ts);
Putc(c, ts);
c = Getc(str);
}
Putc(c,ts);
if (c == '\'') break;
Putc(c, ts);
if (c == '\'')
break;
}
} else if (c == '{') { /* start of {...} */
} else if (c == '{') { /* start of {...} */
empty = 0;
Putc(c,ts);
Putc(c, ts);
if (Len(tf) == 0) {
for (i = 0; i < level; i++)
Putc(' ',tf);
for (i = 0; i < level; i++)
Putc(' ', tf);
} else if ((Len(tf) + Len(ts)) < Max_line_size) {
Putc(' ',tf);
Putc(' ', tf);
} else {
Putc('\n',tf);
Printf(f,"%s", tf);
Putc('\n', tf);
Printf(f, "%s", tf);
Clear(tf);
for (i = 0; i < level; i++)
Putc(' ',tf);
for (i = 0; i < level; i++)
Putc(' ', tf);
}
Append(tf,ts);
Append(tf, ts);
Clear(ts);
level+=indent;
level += indent;
while ((c = Getc(str)) != EOF) {
if (!isspace(c)) {
Ungetc(c,str);
Ungetc(c, str);
break;
}
}
} else if (c == '}') { /* end of {...} */
} else if (c == '}') { /* end of {...} */
empty = 0;
if (Len(tf) == 0) {
for (i = 0; i < level; i++)
Putc(' ',tf);
for (i = 0; i < level; i++)
Putc(' ', tf);
} else if ((Len(tf) + Len(ts)) < Max_line_size) {
Putc(' ',tf);
Putc(' ', tf);
} else {
Putc('\n',tf);
Printf(f,"%s", tf);
Putc('\n', tf);
Printf(f, "%s", tf);
Clear(tf);
for (i = 0; i < level; i++)
Putc(' ',tf);
for (i = 0; i < level; i++)
Putc(' ', tf);
}
Append(tf, ts);
Putc(c, tf);
Clear(ts);
level-=indent;
} else if (c == '\n') { /* line end */
level -= indent;
} else if (c == '\n') { /* line end */
while ((c = Getc(str)) != EOF) {
if (!isspace(c))
break;
}
if (c == '#'){
Putc('\n',ts);
if (c == '#') {
Putc('\n', ts);
} else if (c == '}') {
Putc(' ',ts);
} else if ( (c != EOF) || (Len(ts)!=0) ){
Putc(' ', ts);
} else if ((c != EOF) || (Len(ts) != 0)) {
if (Len(tf) == 0) {
for (i = 0; i < level; i++)
Putc(' ',tf);
for (i = 0; i < level; i++)
Putc(' ', tf);
} else if ((Len(tf) + Len(ts)) < Max_line_size) {
Putc(' ',tf);
Putc(' ', tf);
} else {
Putc('\n',tf);
Printf(f,"%s", tf);
Putc('\n', tf);
Printf(f, "%s", tf);
Clear(tf);
for (i = 0; i < level; i++)
Putc(' ',tf);
for (i = 0; i < level; i++)
Putc(' ', tf);
}
Append(tf,ts);
Append(tf, ts);
Clear(ts);
}
Ungetc(c,str);
Ungetc(c, str);
empty = 1;
} else if (c == '/') { /* comment */
} else if (c == '/') { /* comment */
empty = 0;
c = Getc(str);
if (c != EOF) {
if (c == '/') { /* C++ comment */
if (c == '/') { /* C++ comment */
while ((c = Getc(str)) != EOF) {
if (c == '\n') {
Ungetc(c,str);
Ungetc(c, str);
break;
}
}
} else if (c == '*') { /* C comment */
} else if (c == '*') { /* C comment */
int endstar = 0;
while ((c = Getc(str)) != EOF) {
if (endstar && c == '/') { /* end of C comment */
if (endstar && c == '/') { /* end of C comment */
break;
}
endstar = (c == '*');
endstar = (c == '*');
}
} else {
Putc('/',ts);
Putc(c,ts);
} else {
Putc('/', ts);
Putc(c, ts);
}
}
} else if (c == '#') { /* Preprocessor line */
} else if (c == '#') { /* Preprocessor line */
Putc('#', ts);
while ((c = Getc(str)) != EOF) {
Putc(c, ts);
if (c == '\\') { /* Continued line of the same PP */
if (c == '\\') { /* Continued line of the same PP */
c = Getc(str);
if (c == '\n')
Putc(c, ts);
else
Ungetc(c, str);
} else if (c == '\n')
} else if (c == '\n')
break;
}
if (!empty) {
Append(tf,"\n");
Append(tf, "\n");
}
Append(tf,ts);
Append(tf, ts);
Printf(f, "%s", tf);
Clear(tf);
Clear(ts);
for (i = 0; i < level; i++)
Putc(' ',tf);
for (i = 0; i < level; i++)
Putc(' ', tf);
empty = 1;
} else {
if (!empty || !isspace(c)) {
Putc(c,ts);
Putc(c, ts);
empty = 0;
}
}
}
if (!empty) {
Append(tf,ts);
Append(tf, ts);
}
if (Len(tf) != 0)
Printf(f,"%s",tf);
Printf(f, "%s", tf);
Delete(ts);
Delete(tf);
Printf(f,"\n");
Printf(f, "\n");
}
/* -----------------------------------------------------------------------------
@ -382,18 +384,17 @@ Wrapper_compact_print(String *str, File *f) {
* Print out a wrapper function. Does pretty or compact printing as well.
* ----------------------------------------------------------------------------- */
void
Wrapper_print(Wrapper *w, File *f) {
void Wrapper_print(Wrapper *w, File *f) {
String *str;
str = NewStringEmpty();
Printf(str,"%s\n", w->def);
Printf(str,"%s\n", w->locals);
Printf(str,"%s\n", w->code);
Printf(str, "%s\n", w->def);
Printf(str, "%s\n", w->locals);
Printf(str, "%s\n", w->code);
if (Compact_mode == 1)
Wrapper_compact_print(str,f);
Wrapper_compact_print(str, f);
else
Wrapper_pretty_print(str,f);
Wrapper_pretty_print(str, f);
Delete(str);
}
@ -405,14 +406,13 @@ Wrapper_print(Wrapper *w, File *f) {
* present (which may or may not be okay to the caller).
* ----------------------------------------------------------------------------- */
int
Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
/* See if the local has already been declared */
if (Getattr(w->localh,name)) {
if (Getattr(w->localh, name)) {
return -1;
}
Setattr(w->localh,name,decl);
Printf(w->locals,"%s;\n", decl);
Setattr(w->localh, name, decl);
Printf(w->locals, "%s;\n", decl);
return 0;
}
@ -424,24 +424,23 @@ Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *
* to manually construct the 'decl' string before calling.
* ----------------------------------------------------------------------------- */
int
Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
va_list ap;
int ret;
int ret;
String *decl;
DOH *obj;
DOH *obj;
decl = NewStringEmpty();
va_start(ap,name);
va_start(ap, name);
obj = va_arg(ap,void *);
obj = va_arg(ap, void *);
while (obj) {
Append(decl,obj);
Append(decl, obj);
Putc(' ', decl);
obj = va_arg(ap, void *);
}
va_end(ap);
ret = Wrapper_add_local(w,name,decl);
ret = Wrapper_add_local(w, name, decl);
Delete(decl);
return ret;
}
@ -452,9 +451,8 @@ Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
* Check to see if a local name has already been declared
* ----------------------------------------------------------------------------- */
int
Wrapper_check_local(Wrapper *w, const String_or_char *name) {
if (Getattr(w->localh,name)) {
int Wrapper_check_local(Wrapper *w, const String_or_char *name) {
if (Getattr(w->localh, name)) {
return 1;
}
return 0;
@ -467,27 +465,26 @@ Wrapper_check_local(Wrapper *w, const String_or_char *name) {
* used. Returns the name that was actually selected.
* ----------------------------------------------------------------------------- */
char *
Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
int i;
String *nname = NewString(name);
String *ndecl = NewString(decl);
char *ret;
char *ret;
i = 0;
while (Wrapper_check_local(w,nname)) {
while (Wrapper_check_local(w, nname)) {
Clear(nname);
Printf(nname,"%s%d",name,i);
Printf(nname, "%s%d", name, i);
i++;
}
Replace(ndecl, name, nname, DOH_REPLACE_ID);
Setattr(w->localh,nname,ndecl);
Printf(w->locals,"%s;\n", ndecl);
Setattr(w->localh, nname, ndecl);
Printf(w->locals, "%s;\n", ndecl);
ret = Char(nname);
Delete(nname);
Delete(ndecl);
return ret; /* Note: nname should still exists in the w->localh hash */
return ret; /* Note: nname should still exists in the w->localh hash */
}
@ -499,30 +496,23 @@ Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *
* to manually construct the 'decl' string before calling.
* ----------------------------------------------------------------------------- */
char *
Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...) {
char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...) {
va_list ap;
char *ret;
String *decl;
DOH *obj;
DOH *obj;
decl = NewStringEmpty();
va_start(ap,name);
va_start(ap, name);
obj = va_arg(ap,void *);
obj = va_arg(ap, void *);
while (obj) {
Append(decl,obj);
Putc(' ',decl);
Append(decl, obj);
Putc(' ', decl);
obj = va_arg(ap, void *);
}
va_end(ap);
ret = Wrapper_new_local(w,name,decl);
ret = Wrapper_new_local(w, name, decl);
Delete(decl);
return ret;
}