Merge branch 'master' into gsoc2009-matevz

Conflicts:
	Examples/Makefile.in
	Examples/guile/Makefile.in
	Lib/php/php.swg
	Makefile.in
	Source/CParse/parser.y
	configure.ac
This commit is contained in:
William S Fulton 2013-10-10 07:26:09 +01:00
commit bcb7aee022
585 changed files with 9528 additions and 12959 deletions

View file

@ -865,7 +865,7 @@ void Swig_replace_special_variables(Node *n, Node *parentnode, String *code) {
* ----------------------------------------------------------------------------- */
static String *extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) {
String *parms_str = cplusplus ? ParmList_str_defaultargs(parms) : ParmList_str(parms);
String *sig = NewStringf("%s(%s)", function_name, parms_str);
String *sig = NewStringf("%s(%s)", function_name, (cplusplus || Len(parms_str)) ? parms_str : "void");
String *rt_sig = SwigType_str(return_type, sig);
String *body = NewStringf("SWIGINTERN %s", rt_sig);
Printv(body, code, "\n", NIL);

View file

@ -18,6 +18,7 @@
#include "swig.h"
#include "swigwarn.h"
#include "cparse.h"
static Hash *fragments = 0;
static Hash *looking_fragments = 0;
@ -60,6 +61,8 @@ void Swig_fragment_register(Node *fragment) {
}
Setfile(ccode, Getfile(fragment));
Setline(ccode, Getline(fragment));
/* Replace $descriptor() macros */
Swig_cparse_replace_descriptor(ccode);
Setattr(fragments, name, ccode);
if (debug)
Printf(stdout, "registering fragment %s %s\n", name, section);

View file

@ -163,7 +163,8 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
String *filename;
List *spath = 0;
char *cname;
int i, ilen;
int i, ilen, nbytes;
char bom[3];
if (!directories)
directories = NewList();
@ -191,6 +192,14 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
if (f) {
Delete(lastpath);
lastpath = filename;
/* Skip the UTF-8 BOM if it's present */
nbytes = fread(bom, 1, 3, f);
if (nbytes == 3 && bom[0] == (char)0xEF && bom[1] == (char)0xBB && bom[2] == (char)0xBF) {
/* skip */
} else {
fseek(f, 0, SEEK_SET);
}
}
return f;
}

View file

@ -72,11 +72,11 @@ void Swig_banner(File *f) {
Printf(f, "/* ----------------------------------------------------------------------------\n\
* This file was automatically generated by SWIG (http://www.swig.org).\n\
* Version %s\n\
* \n\
* This file is not intended to be easily readable and contains a number of \n\
*\n\
* This file is not intended to be easily readable and contains a number of\n\
* coding conventions designed to improve portability and efficiency. Do not make\n\
* changes to this file unless you know what you are doing--modify the SWIG \n\
* interface file instead. \n", Swig_package_version());
* changes to this file unless you know what you are doing--modify the SWIG\n\
* interface file instead.\n", Swig_package_version());
/* String too long for ISO compliance */
Printf(f, " * ----------------------------------------------------------------------------- */\n");
@ -205,8 +205,8 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) {
/* -----------------------------------------------------------------------------
* Swig_filename_correct()
*
* Corrects filename paths by removing duplicate delimeters and on non-unix
* systems use the correct delimeter across the whole name.
* Corrects filename paths by removing duplicate delimiters and on non-unix
* systems use the correct delimiter across the whole name.
* ----------------------------------------------------------------------------- */
void Swig_filename_correct(String *filename) {

View file

@ -1405,7 +1405,7 @@ void Scanner_skip_line(Scanner * s) {
if ((c = nextchar(s)) == 0)
return;
if (c == '\\') {
c = nextchar(s);
nextchar(s);
} else if (c == '\n') {
done = 1;
}

View file

@ -659,7 +659,6 @@ SwigType *SwigType_ltype(const SwigType *s) {
if (td && (SwigType_isconst(td) || SwigType_isarray(td) || SwigType_isreference(td) || SwigType_isrvalue_reference(td))) {
/* We need to use the typedef type */
Delete(tt);
tt = td;
break;
} else if (td) {
Delete(tt);

View file

@ -16,6 +16,7 @@
#include "swig.h"
#include <ctype.h>
#include <limits.h>
/* -----------------------------------------------------------------------------
* Synopsis
@ -464,61 +465,60 @@ int SwigType_isrvalue_reference(const SwigType *t) {
* Repeated qualifications have no effect. Moreover, the order of qualifications
* is alphabetical---meaning that "const volatile" and "volatile const" are
* stored in exactly the same way as "q(const volatile)".
* 'qual' can be a list of multiple qualifiers in any order, separated by spaces.
* ----------------------------------------------------------------------------- */
SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
String *newq;
int sz, added = 0;
char *q, *cqual;
List *qlist;
String *allq, *newq;
int i, sz;
const char *cqprev = 0;
const char *c = Char(t);
const char *cqual = Char(qual);
char *c = Char(t);
cqual = Char(qual);
if (!(strncmp(c, "q(", 2) == 0)) {
/* if 't' has no qualifiers and 'qual' is a single qualifier, simply add it */
if ((strncmp(c, "q(", 2) != 0) && (strstr(cqual, " ") == 0)) {
String *temp = NewStringf("q(%s).", cqual);
Insert(t, 0, temp);
Delete(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.
If it is a new qualifier, we add it to the qualifier list in alphabetical
order */
sz = element_size(c);
if (strstr(c, cqual)) {
/* Qualifier already added */
return t;
/* create string of all qualifiers */
if (strncmp(c, "q(", 2) == 0) {
allq = SwigType_parm(t);
Append(allq, " ");
SwigType_del_element(t); /* delete old qualifier list from 't' */
} else {
allq = NewStringEmpty();
}
Append(allq, qual);
/* Add the qualifier to the existing list. */
/* create list of all qualifiers from string */
qlist = Split(allq, ' ', INT_MAX);
Delete(allq);
/* sort in alphabetical order */
SortList(qlist, Strcmp);
/* create new qualifier string from unique elements of list */
sz = Len(qlist);
newq = NewString("q(");
q = c + 2;
q = strtok(q, " ).");
while (q) {
if (strcmp(cqual, q) < 0) {
/* New qualifier is less that current qualifier. We need to insert it */
Append(newq, cqual);
Append(newq, " ");
Append(newq, q);
added = 1;
} else {
for (i = 0; i < sz; ++i) {
String *q = Getitem(qlist, i);
const char *cq = Char(q);
if (cqprev == 0 || strcmp(cqprev, cq) != 0) {
if (i > 0) {
Append(newq, " ");
}
Append(newq, q);
cqprev = cq;
}
q = strtok(NULL, " ).");
if (q) {
Append(newq, " ");
}
}
if (!added) {
Append(newq, " ");
Append(newq, cqual);
}
Append(newq, ").");
Delslice(t, 0, sz);
Delete(qlist);
/* replace qualifier string with new one */
Insert(t, 0, newq);
Delete(newq);
return t;
@ -785,7 +785,6 @@ SwigType *SwigType_add_function(SwigType *t, ParmList *parms) {
Insert(t, 0, ").");
pstr = NewString("f(");
p = parms;
for (p = parms; p; p = nextSibling(p)) {
if (p != parms)
Putc(',', pstr);
@ -883,7 +882,6 @@ SwigType *SwigType_add_template(SwigType *t, ParmList *parms) {
Parm *p;
Append(t, "<(");
p = parms;
for (p = parms; p; p = nextSibling(p)) {
String *v;
if (Getattr(p, "default"))

View file

@ -792,6 +792,67 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
goto return_result;
}
Delete(base);
/* If 'type' is an array, then the right-most qualifier in 'r' should
be added to 'type' after the array qualifier, so that given
a(7).q(volatile).double myarray // typedef volatile double[7] myarray;
the type
q(const).myarray // const myarray
becomes
a(7).q(const volatile).double // const volatile double[7]
and NOT
q(const).a(7).q(volatile).double // non-sensical type
*/
if (r && Len(r) && SwigType_isarray(type)) {
List *r_elem;
String *r_qual;
int r_sz;
r_elem = SwigType_split(r);
r_sz = Len(r_elem);
r_qual = Getitem(r_elem, r_sz-1);
if (SwigType_isqualifier(r_qual)) {
String *new_r;
String *new_type;
List *type_elem;
String *type_qual;
String *r_qual_arg;
int i, type_sz;
type_elem = SwigType_split(type);
type_sz = Len(type_elem);
for (i = 0; i < type_sz; ++i) {
String *e = Getitem(type_elem, i);
if (!SwigType_isarray(e))
break;
}
type_qual = Copy(Getitem(type_elem, i));
r_qual_arg = SwigType_parm(r_qual);
SwigType_add_qualifier(type_qual, r_qual_arg);
Delete(r_qual_arg);
Setitem(type_elem, i, type_qual);
new_r = NewStringEmpty();
for (i = 0; i < r_sz-1; ++i) {
Append(new_r, Getitem(r_elem, i));
}
new_type = NewStringEmpty();
for (i = 0; i < type_sz; ++i) {
Append(new_type, Getitem(type_elem, i));
}
#ifdef SWIG_DEBUG
Printf(stdout, "r+type='%s%s' new_r+new_type='%s%s'\n", r, type, new_r, new_type);
#endif
Delete(r);
r = new_r;
newtype = 1;
type = new_type;
Delete(type_elem);
}
Delete(r_elem);
}
Append(r, type);
if (newtype) {
Delete(type);