Merged changes from trunk up to revision 12416.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12417 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Stefan Zager 2011-01-30 05:24:00 +00:00
commit 9c796f0333
127 changed files with 2571 additions and 1771 deletions

View file

@ -277,9 +277,9 @@ extern int DohGetmark(DOH *obj);
* ----------------------------------------------------------------------------- */
extern DOHString *DohNewStringEmpty(void);
extern DOHString *DohNewString(const DOH *c);
extern DOHString *DohNewStringWithSize(const DOH *c, int len);
extern DOHString *DohNewStringf(const DOH *fmt, ...);
extern DOHString *DohNewString(const DOHString_or_char *c);
extern DOHString *DohNewStringWithSize(const DOHString_or_char *c, int len);
extern DOHString *DohNewStringf(const DOHString_or_char *fmt, ...);
extern int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2);
extern int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n);

View file

@ -54,7 +54,7 @@ typedef struct {
/* String methods */
typedef struct {
int (*doh_replace) (DOH *obj, DOH *old, DOH *rep, int flags);
int (*doh_replace) (DOH *obj, const DOHString_or_char *old, const DOHString_or_char *rep, int flags);
void (*doh_chop) (DOH *obj);
} DohStringMethods;

View file

@ -363,7 +363,7 @@ static DohIterator Hash_nextiter(DohIterator iter) {
}
/* -----------------------------------------------------------------------------
* Hash_keys(DOH *)
* Hash_keys()
*
* Return a list of keys
* ----------------------------------------------------------------------------- */

View file

@ -29,7 +29,7 @@ typedef struct String {
} String;
/* -----------------------------------------------------------------------------
* void *String_data() - Return as a 'void *'
* String_data() - Return as a 'void *'
* ----------------------------------------------------------------------------- */
static void *String_data(DOH *so) {
@ -44,7 +44,7 @@ static void *String_data(DOH *so) {
*/
/* -----------------------------------------------------------------------------
* int String_dump() - Serialize a string onto out
* String_dump() - Serialize a string onto out
* ----------------------------------------------------------------------------- */
static int String_dump(DOH *so, DOH *out) {
@ -105,7 +105,7 @@ static int String_len(DOH *so) {
/* -----------------------------------------------------------------------------
* int String_cmp() - Compare two strings
* String_cmp() - Compare two strings
* ----------------------------------------------------------------------------- */
static int String_cmp(DOH *so1, DOH *so2) {
@ -137,7 +137,7 @@ static int String_cmp(DOH *so1, DOH *so2) {
}
/* -----------------------------------------------------------------------------
* int String_equal() - Say if two string are equal
* String_equal() - Say if two string are equal
* ----------------------------------------------------------------------------- */
static int String_equal(DOH *so1, DOH *so2) {
@ -174,7 +174,7 @@ static int String_equal(DOH *so1, DOH *so2) {
}
/* -----------------------------------------------------------------------------
* int String_hash() - Compute string hash value
* String_hash() - Compute string hash value
* ----------------------------------------------------------------------------- */
static int String_hash(DOH *so) {
@ -203,10 +203,10 @@ static int String_hash(DOH *so) {
}
/* -----------------------------------------------------------------------------
* DohString_append(String *s, const char *newstr) - Append to s
* DohString_append() - Append to s
* ----------------------------------------------------------------------------- */
void DohString_append(DOH *so, DOH *str) {
static void DohString_append(DOH *so, const DOHString_or_char *str) {
int oldlen, newlen, newmaxsize, l, sp;
char *tc;
String *s = (String *) ObjData(so);
@ -251,7 +251,7 @@ void DohString_append(DOH *so, DOH *str) {
/* -----------------------------------------------------------------------------
* void String_clear() - Clear a string
* String_clear() - Clear a string
* ----------------------------------------------------------------------------- */
static void String_clear(DOH *so) {
@ -264,7 +264,7 @@ static void String_clear(DOH *so) {
}
/* -----------------------------------------------------------------------------
* void String_insert() - Insert a string
* String_insert() - Insert a string
* ----------------------------------------------------------------------------- */
static int String_insert(DOH *so, int pos, DOH *str) {
@ -320,7 +320,7 @@ static int String_insert(DOH *so, int pos, DOH *str) {
}
/* -----------------------------------------------------------------------------
* int String_delitem() - Delete a character
* String_delitem() - Delete a character
* ----------------------------------------------------------------------------- */
static int String_delitem(DOH *so, int pos) {
@ -346,7 +346,7 @@ static int String_delitem(DOH *so, int pos) {
}
/* -----------------------------------------------------------------------------
* int String_delslice() - Delete a range
* String_delslice() - Delete a range
* ----------------------------------------------------------------------------- */
static int String_delslice(DOH *so, int sindex, int eindex) {
@ -384,7 +384,7 @@ static int String_delslice(DOH *so, int sindex, int eindex) {
}
/* -----------------------------------------------------------------------------
* DOH *String_str() - Returns a string (used by printing commands)
* String_str() - Returns a string (used by printing commands)
* ----------------------------------------------------------------------------- */
static DOH *String_str(DOH *so) {
@ -394,7 +394,7 @@ static DOH *String_str(DOH *so) {
}
/* -----------------------------------------------------------------------------
* int String_read() - Read data from a string
* String_read() - Read data from a string
* ----------------------------------------------------------------------------- */
static int String_read(DOH *so, void *buffer, int len) {
@ -417,7 +417,7 @@ static int String_read(DOH *so, void *buffer, int len) {
}
/* -----------------------------------------------------------------------------
* int String_write() - Write data to a string
* String_write() - Write data to a string
* ----------------------------------------------------------------------------- */
static int String_write(DOH *so, const void *buffer, int len) {
int newlen;
@ -441,7 +441,7 @@ static int String_write(DOH *so, const void *buffer, int len) {
}
/* -----------------------------------------------------------------------------
* int String_seek() - Seek to a new position
* String_seek() - Seek to a new position
* ----------------------------------------------------------------------------- */
static int String_seek(DOH *so, long offset, int whence) {
@ -498,7 +498,7 @@ static int String_seek(DOH *so, long offset, int whence) {
}
/* -----------------------------------------------------------------------------
* long String_tell() - Return current position
* String_tell() - Return current position
* ----------------------------------------------------------------------------- */
static long String_tell(DOH *so) {
@ -507,7 +507,7 @@ static long String_tell(DOH *so) {
}
/* -----------------------------------------------------------------------------
* int String_putc()
* String_putc()
* ----------------------------------------------------------------------------- */
static int String_putc(DOH *so, int ch) {
@ -538,7 +538,7 @@ static int String_putc(DOH *so, int ch) {
}
/* -----------------------------------------------------------------------------
* int String_getc()
* String_getc()
* ----------------------------------------------------------------------------- */
static int String_getc(DOH *so) {
@ -554,7 +554,7 @@ static int String_getc(DOH *so) {
}
/* -----------------------------------------------------------------------------
* int String_ungetc()
* String_ungetc()
* ----------------------------------------------------------------------------- */
static int String_ungetc(DOH *so, int ch) {
@ -569,12 +569,6 @@ static int String_ungetc(DOH *so, int ch) {
return ch;
}
/* -----------------------------------------------------------------------------
* replace_simple(String *str, char *token, char *rep, int flags, int count)
*
* Replaces count non-overlapping occurrences of token with rep in a string.
* ----------------------------------------------------------------------------- */
static char *end_quote(char *s) {
char *qs;
char qc;
@ -659,6 +653,12 @@ static char *match_identifier_end(char *base, char *s, char *token, int tokenlen
return 0;
}
/* -----------------------------------------------------------------------------
* replace_simple()
*
* Replaces count non-overlapping occurrences of token with rep in a string.
* ----------------------------------------------------------------------------- */
static int replace_simple(String *str, char *token, char *rep, int flags, int count, char *(*match) (char *, char *, char *, int)) {
int tokenlen; /* Length of the token */
int replen; /* Length of the replacement */
@ -885,10 +885,10 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co
}
/* -----------------------------------------------------------------------------
* int String_replace()
* String_replace()
* ----------------------------------------------------------------------------- */
static int String_replace(DOH *stro, DOH *token, DOH *rep, int flags) {
static int String_replace(DOH *stro, const DOHString_or_char *token, const DOHString_or_char *rep, int flags) {
int count = -1;
String *str = (String *) ObjData(stro);
@ -907,7 +907,7 @@ static int String_replace(DOH *stro, DOH *token, DOH *rep, int flags) {
}
/* -----------------------------------------------------------------------------
* void String_chop(DOH *str)
* String_chop()
* ----------------------------------------------------------------------------- */
static void String_chop(DOH *so) {
@ -1012,10 +1012,10 @@ DohObjInfo DohStringType = {
#define INIT_MAXSIZE 16
/* -----------------------------------------------------------------------------
* NewString(const char *c) - Create a new string
* NewString() - Create a new string
* ----------------------------------------------------------------------------- */
DOHString *DohNewString(const DOH *so) {
DOHString *DohNewString(const DOHString_or_char *so) {
int l = 0, max;
String *str;
char *s;
@ -1073,10 +1073,10 @@ DOHString *DohNewStringEmpty(void) {
}
/* -----------------------------------------------------------------------------
* NewStringWithSize(const char *c, int len) - Create a new string
* NewStringWithSize() - Create a new string
* ----------------------------------------------------------------------------- */
DOHString *DohNewStringWithSize(const DOH *so, int len) {
DOHString *DohNewStringWithSize(const DOHString_or_char *so, int len) {
int l = 0, max;
String *str;
char *s;
@ -1111,12 +1111,12 @@ DOHString *DohNewStringWithSize(const DOH *so, int len) {
}
/* -----------------------------------------------------------------------------
* NewStringf(DOH *fmt, ...)
* NewStringf()
*
* Create a new string from a list of objects.
* ----------------------------------------------------------------------------- */
DOHString *DohNewStringf(const DOH *fmt, ...) {
DOHString *DohNewStringf(const DOHString_or_char *fmt, ...) {
va_list ap;
DOH *r;
va_start(ap, fmt);

View file

@ -193,6 +193,7 @@
#define WARN_LANG_DIRECTOR_ABSTRACT 517
#define WARN_LANG_PORTABILITY_FILENAME 518
#define WARN_LANG_TEMPLATE_METHOD_IGNORE 519
#define WARN_LANG_SMARTPTR_MISSING 520
/* -- Reserved (600-799) -- */

View file

@ -2343,6 +2343,7 @@ public:
SwigType *pt = Getattr(p, "type");
if ((tm = Getattr(p, "tmap:csvarin"))) {
substituteClassname(pt, tm);
Replaceall(tm, "$csinput", "value");
Replaceall(tm, "$imcall", imcall);
excodeSubstitute(n, tm, "csvarin", p);
Printf(proxy_class_code, "%s", tm);
@ -3472,7 +3473,6 @@ public:
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
int gencomma = 0;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
// Kludge Alert: functionWrapper sets sym:overload properly, but it
@ -3616,14 +3616,14 @@ public:
Printf(w->code, "} else {\n");
/* Go through argument list, convert from native to Java */
for (p = l; p; /* empty */ ) {
for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
p = Getattr(p, "tmap:directorin:next");
}
SwigType *pt = Getattr(p, "type");
String *ln = Copy(Getattr(p, "name"));
String *ln = makeParameterName(n, p, i, false);
String *c_param_type = NULL;
String *c_decl = NewString("");
String *arg = NewString("");
@ -3631,7 +3631,7 @@ public:
Printf(arg, "j%s", ln);
/* And add to the upcall args */
if (gencomma > 0)
if (i > 0)
Printf(jupcall_args, ", ");
Printf(jupcall_args, "%s", arg);
@ -3659,7 +3659,7 @@ public:
Delete(tm);
/* Add C type to callback typedef */
if (gencomma > 0)
if (i > 0)
Printf(callback_typedef_parms, ", ");
Printf(callback_typedef_parms, "%s", c_param_type);
@ -3680,7 +3680,7 @@ public:
substituteClassname(pt, din);
Replaceall(din, "$iminput", ln);
if (gencomma > 0) {
if (i > 0) {
Printf(delegate_parms, ", ");
Printf(proxy_method_types, ", ");
Printf(imcall_args, ", ");
@ -3726,7 +3726,7 @@ public:
p = nextSibling(p);
}
gencomma++;
Delete(ln);
Delete(arg);
Delete(c_decl);
Delete(c_param_type);

View file

@ -1867,7 +1867,6 @@ public:
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
int gencomma = 0;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
// Kludge Alert: functionWrapper sets sym:overload properly, but it
@ -2007,14 +2006,14 @@ public:
Printf(w->code, "} else {\n");
// Go through argument list.
for (p = l; p; /* empty */) {
for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
p = Getattr(p, "tmap:directorin:next");
}
SwigType *pt = Getattr(p, "type");
String *ln = Copy(Getattr(p, "name"));
String *ln = makeParameterName(n, p, i, false);
String *c_param_type = NULL;
String *c_decl = NewString("");
String *arg = NewString("");
@ -2071,7 +2070,7 @@ public:
Replaceall(din, "$winput", ln);
Printf(delegate_parms, ", ");
if (gencomma > 0) {
if (i > 0) {
Printf(proxy_method_param_list, ", ");
Printf(imcall_args, ", ");
}
@ -2123,10 +2122,10 @@ public:
p = nextSibling(p);
}
gencomma++;
Delete(arg);
Delete(c_decl);
Delete(c_param_type);
Delete(ln);
}
/* header declaration, start wrapper definition */
@ -2631,6 +2630,8 @@ private:
if (!static_flag) {
Printf(imcall, "cast(void*)swigCPtr");
}
String *proxy_param_types = NewString("");
// Write the parameter list for the proxy function declaration and the
// wrapper function call.
@ -2705,10 +2706,13 @@ private:
"No dtype typemap defined for %s\n", SwigType_str(pt, 0));
}
if (gencomma >= 2)
if (gencomma >= 2) {
Printf(function_code, ", ");
Printf(proxy_param_types, ", ");
}
gencomma = 2;
Printf(function_code, "%s %s", proxy_type, param_name);
Append(proxy_param_types, proxy_type);
Delete(proxy_type);
}
@ -2773,9 +2777,11 @@ private:
String *excode = NewString("");
if (!Cmp(return_type, "void"))
Printf(excode, "if (this.classinfo == %s.classinfo) %s; else %s", proxy_class_name, imcall, ex_imcall);
Printf(excode, "if (swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) %s; else %s",
return_type, proxy_param_types, return_type, proxy_param_types, proxy_function_name, ex_imcall, imcall);
else
Printf(excode, "((this.classinfo == %s.classinfo) ? %s : %s)", proxy_class_name, imcall, ex_imcall);
Printf(excode, "((swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) ? %s : %s)",
return_type, proxy_param_types, return_type, proxy_param_types, proxy_function_name, ex_imcall, imcall);
Clear(imcall);
Printv(imcall, excode, NIL);
@ -2789,6 +2795,8 @@ private:
Swig_warning(WARN_D_TYPEMAP_DOUT_UNDEF, input_file, line_number,
"No dout typemap defined for %s\n", SwigType_str(t, 0));
}
Delete(proxy_param_types);
// The whole function body is now in stored tm (if there was a matching type
// map, of course), so simply append it to the code buffer. The braces are
@ -3419,7 +3427,7 @@ private:
// Only emit it if the proxy class has at least one method.
if (first_class_dmethod < curr_class_dmethod) {
Printf(proxy_class_body_code, "\n");
Printf(proxy_class_body_code, "private bool swigIsMethodOverridden(DelegateType, FunctionType, alias fn)() {\n");
Printf(proxy_class_body_code, "private bool swigIsMethodOverridden(DelegateType, FunctionType, alias fn)() %s{\n", (d_version > 1) ? "const " : "");
Printf(proxy_class_body_code, " DelegateType dg = &fn;\n");
Printf(proxy_class_body_code, " return dg.funcptr != SwigNonVirtualAddressOf!(FunctionType, fn);\n");
Printf(proxy_class_body_code, "}\n");
@ -3653,7 +3661,7 @@ private:
String *getPrimitiveDptype(Node *node, SwigType *type) {
SwigType *stripped_type = SwigType_typedef_resolve_all(type);
// A reference can only be the »outermost element« of a typ.
// A reference can only be the »outermost element« of a type.
bool mutable_ref = false;
if (SwigType_isreference(stripped_type)) {
SwigType_del_reference(stripped_type);

View file

@ -43,11 +43,9 @@ class GO:public Language {
File *f_go_runtime;
File *f_go_header;
File *f_go_wrappers;
File *f_go_once;
File *f_gc_runtime;
File *f_gc_header;
File *f_gc_wrappers;
File *f_gc_once;
// True if we imported a module.
bool saw_import;
@ -100,11 +98,9 @@ public:
f_go_runtime(NULL),
f_go_header(NULL),
f_go_wrappers(NULL),
f_go_once(NULL),
f_gc_runtime(NULL),
f_gc_header(NULL),
f_gc_wrappers(NULL),
f_gc_once(NULL),
saw_import(false),
imported_package(NULL),
interfaces(NULL),
@ -303,12 +299,10 @@ private:
f_go_runtime = NewString("");
f_go_header = NewString("");
f_go_wrappers = NewString("");
f_go_once = NewString("");
if (!gccgo_flag) {
f_gc_runtime = NewString("");
f_gc_header = NewString("");
f_gc_wrappers = NewString("");
f_gc_once = NewString("");
}
Swig_register_filebyname("begin", f_c_begin);
@ -322,13 +316,11 @@ private:
Swig_register_filebyname("go_runtime", f_go_runtime);
Swig_register_filebyname("go_header", f_go_header);
Swig_register_filebyname("go_wrapper", f_go_wrappers);
Swig_register_filebyname("go_once", f_go_once);
if (!gccgo_flag) {
Swig_register_filebyname("gc_begin", f_gc_begin);
Swig_register_filebyname("gc_runtime", f_gc_runtime);
Swig_register_filebyname("gc_header", f_gc_header);
Swig_register_filebyname("gc_wrapper", f_gc_wrappers);
Swig_register_filebyname("gc_once", f_gc_once);
}
Swig_banner(f_c_begin);
@ -349,6 +341,7 @@ private:
if (!gccgo_flag) {
Swig_banner(f_gc_begin);
Printf(f_gc_begin, "\n/* This file should be compiled with 6c/8c. */\n");
Printf(f_gc_begin, "#pragma dynimport _ _ \"%s\"\n", soname);
}
// Output module initialization code.
@ -414,16 +407,10 @@ private:
Dump(f_c_wrappers, f_c_begin);
Dump(f_c_init, f_c_begin);
Dump(f_go_header, f_go_begin);
if (!saw_import) {
Dump(f_go_once, f_go_begin);
}
Dump(f_go_runtime, f_go_begin);
Dump(f_go_wrappers, f_go_begin);
if (!gccgo_flag) {
Dump(f_gc_header, f_gc_begin);
if (!saw_import) {
Dump(f_gc_once, f_gc_begin);
}
Dump(f_gc_runtime, f_gc_begin);
Dump(f_gc_wrappers, f_gc_begin);
}
@ -1011,8 +998,9 @@ private:
int gcFunctionWrapper(Node *n, String *name, String *go_name, String *overname, String *wname, ParmList *parms, SwigType *result, bool is_static, bool needs_wrapper) {
Wrapper *f = NewWrapper();
Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"", soname, "\"\n", NULL);
Printv(f->def, "void (*", wname, ")(void*);\n", NULL);
Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"\"\n", NULL);
Printv(f->def, "extern void (*", wname, ")(void*);\n", NULL);
Printv(f->def, "static void (*x", wname, ")(void*) = ", wname, ";\n", NULL);
Printv(f->def, "\n", NULL);
Printv(f->def, "void\n", NULL);
@ -1068,7 +1056,7 @@ private:
Delete(parm_size);
Printv(f->code, "{\n", NULL);
Printv(f->code, "\truntime\xc2\xb7" "cgocall(", wname, ", &p);\n", NULL);
Printv(f->code, "\truntime\xc2\xb7" "cgocall(x", wname, ", &p);\n", NULL);
Printv(f->code, "}\n", NULL);
Printv(f->code, "\n", NULL);
@ -1166,7 +1154,7 @@ private:
p = nextParm(p);
}
if (SwigType_type(result) != T_VOID) {
Printv(f->code, "\t\tint : 0;\n", NULL);
Printv(f->code, "\t\tlong : 0;\n", NULL);
String *ln = NewString("result");
String *ct = gcCTypeForGoValue(n, result, ln);
Delete(ln);
@ -1270,7 +1258,11 @@ private:
Parm *p = parms;
for (int i = 0; i < parm_count; ++i) {
p = getParm(p);
SwigType *pt = Getattr(p, "type");
SwigType *pt = Copy(Getattr(p, "type"));
if (SwigType_isarray(pt)) {
SwigType_del_array(pt);
SwigType_add_pointer(pt);
}
String *pn = NewString("g");
Append(pn, Getattr(p, "lname"));
String *ct = gccgoCTypeForGoValue(p, pt, pn);
@ -1280,6 +1272,7 @@ private:
Printv(fnname, ct, NULL);
Delete(ct);
Delete(pn);
Delete(pt);
p = nextParm(p);
}
@ -3415,7 +3408,7 @@ private:
p = Getattr(p, "tmap:directorin:next");
}
if (SwigType_type(result) != T_VOID) {
Printv(f->code, " int : 0;\n", NULL);
Printv(f->code, " long : 0;\n", NULL);
String *rname = NewString("result");
String *cg = gcCTypeForGoValue(n, result, rname);
Printv(f->code, " ", cg, ";\n", NULL);
@ -3545,7 +3538,7 @@ private:
}
} else {
assert(is_pure_virtual);
Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n");
Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL);
if (SwigType_type(result) != T_VOID) {
String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result");
Printv(f->code, " return ", retstr, ";\n", NULL);

View file

@ -3548,7 +3548,6 @@ public:
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
int gencomma = 0;
int classmeth_off = curr_class_dmethod - first_class_dmethod;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
@ -3767,14 +3766,14 @@ public:
Delete(tp);
/* Go through argument list, convert from native to Java */
for (p = l; p; /* empty */ ) {
for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
p = Getattr(p, "tmap:directorin:next");
}
SwigType *pt = Getattr(p, "type");
String *ln = Copy(Getattr(p, "name"));
String *ln = makeParameterName(n, p, i, false);
String *c_param_type = NULL;
String *c_decl = NewString("");
String *arg = NewString("");
@ -3833,7 +3832,7 @@ public:
substituteClassname(pt, din);
Replaceall(din, "$jniinput", ln);
if (++gencomma > 1)
if (i > 0)
Printf(imcall_args, ", ");
Printf(callback_def, ", %s %s", tm, ln);
@ -3896,6 +3895,7 @@ public:
Delete(arg);
Delete(c_decl);
Delete(c_param_type);
Delete(ln);
}
/* header declaration, start wrapper definition */

View file

@ -3011,7 +3011,7 @@ Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
* Tries to locate a class from a type definition
* ----------------------------------------------------------------------------- */
Node *Language::classLookup(SwigType *s) {
Node *Language::classLookup(const SwigType *s) {
Node *n = 0;
/* Look in hash of cached values */

View file

@ -35,7 +35,7 @@ static String *classname = 0;
static String *module = 0;
static String *init_func_def = 0;
static String *f_classtemplate = 0;
static String *name_qualifier = 0;
static SwigType *name_qualifier_type = 0;
static Hash *seen_enums = 0;
static Hash *seen_enumvalues = 0;
@ -898,12 +898,12 @@ public:
String *name = Getattr(n, "feature:symname");
SwigType *type = Getattr(n, "type");
String *value = Getattr(n, "value");
String *qvalue = Getattr(n, "qualified:value");
SwigType *qname = Getattr(n, "qualified:name");
String *rvalue = NewString("");
String *temp = 0;
if (qvalue)
value = qvalue;
if (qname)
value = qname;
if (!name) {
name = mangleNameForCaml(Getattr(n, "name"));
@ -1228,20 +1228,18 @@ public:
return out;
}
String *fully_qualify_enum_name(Node *n, String *name) {
SwigType *fully_qualified_enum_type(Node *n) {
Node *parent = 0;
String *qualification = NewString("");
String *fully_qualified_name = NewString("");
String *parent_type = 0;
String *normalized_name;
parent = parentNode(n);
while (parent) {
parent_type = nodeType(parent);
if (Getattr(parent, "name")) {
String *parent_copy = NewStringf("%s::", Getattr(parent, "name"));
if (!Cmp(parent_type, "class") || !Cmp(parent_type, "namespace"))
Insert(qualification, 0, parent_copy);
if (Cmp(parent_type, "class") == 0 || Cmp(parent_type, "namespace") == 0)
Insert(fully_qualified_name, 0, parent_copy);
Delete(parent_copy);
}
if (!Cmp(parent_type, "class"))
@ -1249,25 +1247,18 @@ public:
parent = parentNode(parent);
}
Printf(fully_qualified_name, "%s%s", qualification, name);
normalized_name = normalizeTemplatedClassName(fully_qualified_name);
if (!strncmp(Char(normalized_name), "enum ", 5)) {
Insert(normalized_name, 5, qualification);
}
return normalized_name;
return fully_qualified_name;
}
/* Benedikt Grundmann inspired --> Enum wrap styles */
int enumvalueDeclaration(Node *n) {
String *name = Getattr(n, "name");
String *qvalue = 0;
SwigType *qtype = 0;
if (name_qualifier) {
qvalue = Copy(name_qualifier);
Printv(qvalue, name, NIL);
if (name_qualifier_type) {
qtype = Copy(name_qualifier_type);
Printv(qtype, name, NIL);
}
if (const_enum && name && !Getattr(seen_enumvalues, name)) {
@ -1275,10 +1266,10 @@ public:
SetFlag(n, "feature:immutable");
Setattr(n, "feature:enumvalue", "1"); // this does not appear to be used
if (qvalue)
Setattr(n, "qualified:value", qvalue);
if (qtype)
Setattr(n, "qualified:name", SwigType_namestr(qtype));
String *evname = SwigType_manglestr(qvalue);
String *evname = SwigType_manglestr(qtype);
Insert(evname, 0, "SWIG_ENUM_");
Setattr(n, "feature:enumvname", name);
@ -1309,10 +1300,10 @@ public:
/* name is now fully qualified */
String *fully_qualified_name = NewString(name);
bool seen_enum = false;
if (name_qualifier)
Delete(name_qualifier);
if (name_qualifier_type)
Delete(name_qualifier_type);
char *strip_position;
name_qualifier = fully_qualify_enum_name(n, NewString(""));
name_qualifier_type = fully_qualified_enum_type(n);
strip_position = strstr(Char(oname), "::");

View file

@ -126,7 +126,7 @@ static enum {
} wrapperType = standard;
extern "C" {
static void (*r_prevtracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
static void (*r_prevtracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0;
}
static void SwigPHP_emit_resource_registrations() {
@ -2710,7 +2710,7 @@ static PHP *maininstance = 0;
// We use this function to be able to write out zend_register_list_destructor_ex
// lines for most things in the type table
// NOTE: it's a function NOT A PHP::METHOD
extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) {
extern "C" void typetrace(const SwigType *ty, String *mangled, String *clientdata) {
Node *class_node;
if (!zend_types) {
zend_types = NewHash();

View file

@ -213,7 +213,7 @@ public:
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
virtual void dumpSymbols();
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
virtual Node *classLookup(SwigType *s); /* Class lookup */
virtual Node *classLookup(const SwigType *s); /* Class lookup */
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
virtual int is_assignable(Node *n); /* Is variable assignable? */

View file

@ -254,12 +254,17 @@ class TypePass:private Dispatcher {
Delete(smartnamestr);
/* setup inheritance relationship between smart pointer templates */
SwigType_inherit(smart, bsmart, 0, convcode);
if (!GetFlag(bclass, "feature:smartptr"))
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
Delete(convcode);
Delete(bsmart);
Delete(smart);
} else {
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
}
} else {
if (GetFlag(bclass, "feature:smartptr"))
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
}
if (!importmode) {
String *btype = Copy(bname);

View file

@ -177,7 +177,7 @@ void SwigType_push(SwigType *t, String *cons) {
* Testing functions for querying a raw datatype
* ----------------------------------------------------------------------------- */
int SwigType_ispointer_return(SwigType *t) {
int SwigType_ispointer_return(const SwigType *t) {
char *c;
int idx;
if (!t)
@ -190,7 +190,7 @@ int SwigType_ispointer_return(SwigType *t) {
return 0;
}
int SwigType_isreference_return(SwigType *t) {
int SwigType_isreference_return(const SwigType *t) {
char *c;
int idx;
if (!t)
@ -203,7 +203,7 @@ int SwigType_isreference_return(SwigType *t) {
return 0;
}
int SwigType_isconst(SwigType *t) {
int SwigType_isconst(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -229,7 +229,7 @@ int SwigType_isconst(SwigType *t) {
return 0;
}
int SwigType_ismutable(SwigType *t) {
int SwigType_ismutable(const SwigType *t) {
int r;
SwigType *qt = SwigType_typedef_resolve_all(t);
if (SwigType_isreference(qt) || SwigType_isarray(qt)) {
@ -240,7 +240,7 @@ int SwigType_ismutable(SwigType *t) {
return r ? 0 : 1;
}
int SwigType_isenum(SwigType *t) {
int SwigType_isenum(const SwigType *t) {
char *c = Char(t);
if (!t)
return 0;
@ -250,7 +250,7 @@ int SwigType_isenum(SwigType *t) {
return 0;
}
int SwigType_issimple(SwigType *t) {
int SwigType_issimple(const SwigType *t) {
char *c = Char(t);
if (!t)
return 0;
@ -308,7 +308,7 @@ int SwigType_issimple(SwigType *t) {
* r.q(const).enum SWIGTYPE
* ----------------------------------------------------------------------------- */
SwigType *SwigType_default_create(SwigType *ty) {
SwigType *SwigType_default_create(const SwigType *ty) {
SwigType *r = 0;
List *l;
Iterator it;
@ -387,7 +387,7 @@ SwigType *SwigType_default_create(SwigType *ty) {
* SWIGTYPE
* ----------------------------------------------------------------------------- */
SwigType *SwigType_default_deduce(SwigType *t) {
SwigType *SwigType_default_deduce(const SwigType *t) {
SwigType *r = NewStringEmpty();
List *l;
Iterator it;
@ -511,7 +511,7 @@ String *SwigType_namestr(const SwigType *t) {
* Create a C string representation of a datatype.
* ----------------------------------------------------------------------------- */
String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
String *result;
String *element = 0, *nextelement;
List *elements;
@ -606,12 +606,12 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
}
/* -----------------------------------------------------------------------------
* SwigType_ltype(SwigType *ty)
* SwigType_ltype(const SwigType *ty)
*
* Create a locally assignable type
* ----------------------------------------------------------------------------- */
SwigType *SwigType_ltype(SwigType *s) {
SwigType *SwigType_ltype(const SwigType *s) {
String *result;
String *element;
SwigType *td, *tc = 0;
@ -709,7 +709,7 @@ SwigType *SwigType_ltype(SwigType *s) {
* with an equivalent assignable version.
* -------------------------------------------------------------------- */
String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) {
String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id) {
String *result;
SwigType *tc;
@ -726,10 +726,11 @@ String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) {
* datatype printed by str().
* ----------------------------------------------------------------------------- */
String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
String *result, *cast;
String *element = 0, *nextelement;
SwigType *td, *rs, *tc = 0;
SwigType *td, *tc = 0;
const SwigType *rs;
List *elements;
int nelements, i;
int clear = 1;
@ -873,7 +874,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
* Casts a variable from the real type to the local datatype.
* ----------------------------------------------------------------------------- */
String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) {
String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr name) {
String *result;
result = NewStringEmpty();
@ -899,9 +900,146 @@ String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) {
return result;
}
#if 0
/* Alternative implementation for manglestr_default. Mangling is similar to the original
except for a few subtle differences for example in templates:
namespace foo {
template<class T> class bar {};
typedef int Integer;
void test2(bar<Integer *> *x);
}
Mangling is more consistent and changes from
_p_foo__barT_int_p_t to
_p_foo__barT_p_int_t.
*/
static void mangle_stringcopy(String *destination, const char *source, int count) {
while (count-- > 0) {
char newc = '_';
if (!(*source == '.' || *source == ':' || *source == ' '))
newc = *source;
/* TODO: occasionally '*' or numerics need converting to '_', eg in array dimensions and template expressions */
Putc(newc, destination);
source++;
}
}
/* keep old mangling since Java codes need it */
String *SwigType_manglestr_default(SwigType *s) {
static void mangle_subtype(String *mangled, SwigType *s);
/* -----------------------------------------------------------------------------
* mangle_namestr()
*
* Mangles a type taking care of template expansions. Similar to SwigType_namestr().
* The type may include a trailing '.', for example "p."
* ----------------------------------------------------------------------------- */
static void mangle_namestr(String *mangled, SwigType *t) {
int length = Len(t);
if (SwigType_isqualifier(t)) {
Append(mangled, "q_");
mangle_stringcopy(mangled, Char(t)+2, length-4);
Append(mangled, "__");
} else if (SwigType_ismemberpointer(t)) {
Append(mangled, "m_");
mangle_stringcopy(mangled, Char(t)+2, length-4);
Append(mangled, "__");
} else if (SwigType_isarray(t)) {
Append(mangled, "a_");
mangle_stringcopy(mangled, Char(t)+2, length-4);
Append(mangled, "__");
} else if (SwigType_isfunction(t)) {
List *p = SwigType_parmlist(t);
int sz = Len(p);
int i;
Append(mangled, "f_");
for (i = 0; i < sz; i++) {
mangle_subtype(mangled, Getitem(p, i));
Putc('_', mangled);
}
Append(mangled, (sz > 0) ? "_" : "__");
} else if (SwigType_isvarargs(t)) {
Append(mangled, "___");
} else {
char *d = Char(t);
char *c = strstr(d, "<(");
if (!c || !strstr(c + 2, ")>")) {
/* not a template type */
mangle_stringcopy(mangled, Char(t), Len(t));
} else {
/* a template type */
String *suffix;
List *p;
int i, sz;
mangle_stringcopy(mangled, d, c-d);
Putc('T', mangled);
Putc('_', mangled);
p = SwigType_parmlist(c + 1);
sz = Len(p);
for (i = 0; i < sz; i++) {
mangle_subtype(mangled, Getitem(p, i));
Putc('_', mangled);
}
Putc('t', mangled);
suffix = SwigType_templatesuffix(t);
if (Len(suffix) > 0) {
mangle_namestr(mangled, suffix);
} else {
Append(mangled, suffix);
}
Delete(suffix);
Delete(p);
}
}
}
static void mangle_subtype(String *mangled, SwigType *s) {
List *elements;
int nelements, i;
assert(s);
elements = SwigType_split(s);
nelements = Len(elements);
for (i = 0; i < nelements; i++) {
SwigType *element = Getitem(elements, i);
mangle_namestr(mangled, element);
}
Delete(elements);
}
static String *manglestr_default(const SwigType *s) {
String *mangled = NewString("_");
SwigType *sr = SwigType_typedef_resolve_all(s);
SwigType *sq = SwigType_typedef_qualified(sr);
SwigType *ss = SwigType_remove_global_scope_prefix(sq);
SwigType *type = ss;
SwigType *lt;
if (SwigType_istemplate(ss)) {
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
Delete(ss);
ss = ty;
type = ss;
}
lt = SwigType_ltype(type);
Replace(lt, "struct ", "", DOH_REPLACE_ANY);
Replace(lt, "class ", "", DOH_REPLACE_ANY);
Replace(lt, "union ", "", DOH_REPLACE_ANY);
Replace(lt, "enum ", "", DOH_REPLACE_ANY);
mangle_subtype(mangled, lt);
Delete(ss);
Delete(sq);
Delete(sr);
return mangled;
}
#else
static String *manglestr_default(const SwigType *s) {
char *c;
String *result = 0;
String *base = 0;
@ -909,17 +1047,16 @@ String *SwigType_manglestr_default(SwigType *s) {
SwigType *sr = SwigType_typedef_resolve_all(s);
SwigType *sq = SwigType_typedef_qualified(sr);
SwigType *ss = SwigType_remove_global_scope_prefix(sq);
s = ss;
SwigType *type = ss;
if (SwigType_istemplate(ss)) {
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
Delete(ss);
ss = ty;
s = ss;
type = ss;
}
lt = SwigType_ltype(s);
lt = SwigType_ltype(type);
result = SwigType_prefix(lt);
base = SwigType_base(lt);
@ -971,9 +1108,18 @@ String *SwigType_manglestr_default(SwigType *s) {
Delete(sr);
return result;
}
#endif
String *SwigType_manglestr(SwigType *s) {
return SwigType_manglestr_default(s);
String *SwigType_manglestr(const SwigType *s) {
#if 0
/* Debugging checks to ensure a proper SwigType is passed in and not a stringified type */
String *angle = Strstr(s, "<");
if (angle && Strncmp(angle, "<(", 2) != 0)
Printf(stderr, "SwigType_manglestr error: %s\n", s);
else if (Strstr(s, "*") || Strstr(s, "&") || Strstr(s, "["))
Printf(stderr, "SwigType_manglestr error: %s\n", s);
#endif
return manglestr_default(s);
}
/* -----------------------------------------------------------------------------
@ -1092,7 +1238,7 @@ SwigType *SwigType_remove_global_scope_prefix(const SwigType *t) {
* Checks type declarators for a match
* ----------------------------------------------------------------------------- */
int SwigType_check_decl(SwigType *ty, const SwigType *decl) {
int SwigType_check_decl(const SwigType *ty, const SwigType *decl) {
SwigType *t, *t1, *t2;
int r;
t = SwigType_typedef_resolve_all(ty);

View file

@ -129,37 +129,37 @@ extern "C" {
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, Node *file_line_node);
extern ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node);
extern List *SwigType_split(const SwigType *t);
extern String *SwigType_pop(SwigType *t);
extern void SwigType_push(SwigType *t, SwigType *s);
extern void SwigType_push(SwigType *t, String *s);
extern List *SwigType_parmlist(const SwigType *p);
extern String *SwigType_parm(String *p);
extern String *SwigType_str(SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr 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_isfunctionpointer(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_prefix_is_simple_1D_array(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 String *SwigType_parm(const SwigType *p);
extern String *SwigType_str(const SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_manglestr(const SwigType *t);
extern SwigType *SwigType_ltype(const SwigType *t);
extern int SwigType_ispointer(const SwigType *t);
extern int SwigType_ispointer_return(const SwigType *t);
extern int SwigType_isfunctionpointer(const SwigType *t);
extern int SwigType_ismemberpointer(const SwigType *t);
extern int SwigType_isreference(const SwigType *t);
extern int SwigType_isreference_return(const SwigType *t);
extern int SwigType_isarray(const SwigType *t);
extern int SwigType_prefix_is_simple_1D_array(const SwigType *t);
extern int SwigType_isfunction(const SwigType *t);
extern int SwigType_isqualifier(const SwigType *t);
extern int SwigType_isconst(const SwigType *t);
extern int SwigType_issimple(const SwigType *t);
extern int SwigType_ismutable(const 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_ptr decl);
extern SwigType *SwigType_strip_qualifiers(SwigType *t);
extern SwigType *SwigType_strip_single_qualifier(SwigType *t);
extern int SwigType_isenum(const SwigType *t);
extern int SwigType_check_decl(const SwigType *t, const_String_or_char_ptr decl);
extern SwigType *SwigType_strip_qualifiers(const SwigType *t);
extern SwigType *SwigType_strip_single_qualifier(const SwigType *t);
extern SwigType *SwigType_functionpointer_decompose(SwigType *t);
extern String *SwigType_base(const SwigType *t);
extern String *SwigType_namestr(const SwigType *t);
@ -168,27 +168,26 @@ extern "C" {
extern String *SwigType_istemplate_templateprefix(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 int SwigType_array_ndim(const SwigType *t);
extern String *SwigType_array_getdim(const SwigType *t, int n);
extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep);
extern SwigType *SwigType_array_type(SwigType *t);
extern String *SwigType_default(SwigType *t);
extern SwigType *SwigType_default_create(SwigType *ty);
extern SwigType *SwigType_default_deduce(SwigType *t);
extern SwigType *SwigType_array_type(const SwigType *t);
extern SwigType *SwigType_default_create(const SwigType *ty);
extern SwigType *SwigType_default_deduce(const SwigType *t);
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t);
extern SwigType *SwigType_alttype(SwigType *t, int ltmap);
extern SwigType *SwigType_alttype(const 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);
/* --- Type-system managment --- */
extern void SwigType_typesystem_init(void);
extern int SwigType_typedef(SwigType *type, const_String_or_char_ptr name);
extern int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name);
extern int SwigType_typedef_class(const_String_or_char_ptr name);
extern int SwigType_typedef_using(const_String_or_char_ptr qname);
extern void SwigType_inherit(String *subclass, String *baseclass, String *cast, String *conversioncode);
extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype);
extern int SwigType_issubtype(const SwigType *subtype, const 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_ptr name);
@ -197,17 +196,17 @@ extern "C" {
extern Typetab *SwigType_set_scope(Typetab *h);
extern void SwigType_print_scope(Typetab *t);
extern SwigType *SwigType_typedef_resolve(const 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 SwigType *SwigType_typedef_resolve_all(const SwigType *t);
extern SwigType *SwigType_typedef_qualified(const SwigType *t);
extern int SwigType_istypedef(const SwigType *t);
extern int SwigType_isclass(const 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_ptr clientdata);
extern void SwigType_remember(const SwigType *t);
extern void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata);
extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata);
extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *);
extern void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *);
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
extern int SwigType_type(SwigType *t);
extern int SwigType_type(const SwigType *t);
/* --- Symbol table module --- */
@ -240,7 +239,7 @@ extern "C" {
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 SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab);
extern ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);

View file

@ -1642,7 +1642,7 @@ SwigType *Swig_symbol_template_reduce(SwigType *qt, Symtab *ntab) {
* Chase a typedef through symbol tables looking for a match.
* ----------------------------------------------------------------------------- */
SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab) {
SwigType *prefix, *base;
Node *n;
String *nt;

View file

@ -963,7 +963,7 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
{
SwigType *star_type, *amp_type, *base_type, *lex_type;
SwigType *ltype, *star_ltype, *amp_ltype;
String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name;
String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name, *base_type_str;
String *descriptor, *star_descriptor, *amp_descriptor;
String *ts;
char *sc;
@ -1132,21 +1132,20 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
/* Base type */
if (SwigType_isarray(type)) {
SwigType *bt = Copy(type);
Delete(SwigType_pop_arrays(bt));
base_type = SwigType_str(bt, 0);
Delete(bt);
base_type = Copy(type);
Delete(SwigType_pop_arrays(base_type));
} else {
base_type = SwigType_base(type);
}
base_name = SwigType_namestr(base_type);
base_type_str = SwigType_str(base_type, 0);
base_name = SwigType_namestr(base_type_str);
if (index == 1) {
Replace(s, "$basetype", base_name, DOH_REPLACE_ANY);
replace_local_types(locals, "$basetype", base_name);
}
strcpy(varname, "basetype");
Replace(s, var, base_type, DOH_REPLACE_ANY);
Replace(s, var, base_type_str, DOH_REPLACE_ANY);
replace_local_types(locals, var, base_name);
base_mangle = SwigType_manglestr(base_type);
@ -1155,8 +1154,9 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
strcpy(varname, "basemangle");
Replace(s, var, base_mangle, DOH_REPLACE_ANY);
Delete(base_mangle);
Delete(base_type);
Delete(base_name);
Delete(base_type_str);
Delete(base_type);
lex_type = SwigType_base(rtype);
if (index == 1)
@ -1440,8 +1440,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
num_substitutions = typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1);
}
if (optimal_substitution && num_substitutions > 1) {
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to optimal attribute usage in\n", Swig_name_decl(node));
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "the out typemap.\n");
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to\n", Swig_name_decl(node));
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "optimal attribute usage in the out typemap.\n");
}
if (locals && f) {

View file

@ -210,7 +210,7 @@ SwigType *SwigType_pop(SwigType *t) {
* Returns the parameter of an operator as a string
* ----------------------------------------------------------------------------- */
String *SwigType_parm(SwigType *t) {
String *SwigType_parm(const SwigType *t) {
char *start, *c;
int nparens = 0;
@ -362,7 +362,7 @@ SwigType *SwigType_del_pointer(SwigType *t) {
return t;
}
int SwigType_ispointer(SwigType *t) {
int SwigType_ispointer(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -404,7 +404,7 @@ SwigType *SwigType_del_reference(SwigType *t) {
return t;
}
int SwigType_isreference(SwigType *t) {
int SwigType_isreference(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -494,7 +494,7 @@ SwigType *SwigType_del_qualifier(SwigType *t) {
return t;
}
int SwigType_isqualifier(SwigType *t) {
int SwigType_isqualifier(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -509,7 +509,7 @@ int SwigType_isqualifier(SwigType *t) {
* Function Pointers
* ----------------------------------------------------------------------------- */
int SwigType_isfunctionpointer(SwigType *t) {
int SwigType_isfunctionpointer(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -562,7 +562,7 @@ SwigType *SwigType_del_memberpointer(SwigType *t) {
return t;
}
int SwigType_ismemberpointer(SwigType *t) {
int SwigType_ismemberpointer(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -606,7 +606,7 @@ SwigType *SwigType_del_array(SwigType *t) {
return t;
}
int SwigType_isarray(SwigType *t) {
int SwigType_isarray(const SwigType *t) {
char *c;
if (!t)
return 0;
@ -622,7 +622,7 @@ int SwigType_isarray(SwigType *t) {
* Determine if the type is a 1D array type that is treated as a pointer within SWIG
* eg Foo[], Foo[3] return true, but Foo[3][3], Foo*[], Foo*[3], Foo**[] return false
*/
int SwigType_prefix_is_simple_1D_array(SwigType *t) {
int SwigType_prefix_is_simple_1D_array(const SwigType *t) {
char *c = Char(t);
if (c && (strncmp(c, "a(", 2) == 0)) {
@ -648,7 +648,7 @@ SwigType *SwigType_pop_arrays(SwigType *t) {
}
/* Return number of array dimensions */
int SwigType_array_ndim(SwigType *t) {
int SwigType_array_ndim(const SwigType *t) {
int ndim = 0;
char *c = Char(t);
@ -661,7 +661,7 @@ int SwigType_array_ndim(SwigType *t) {
}
/* Get nth array dimension */
String *SwigType_array_getdim(SwigType *t, int n) {
String *SwigType_array_getdim(const SwigType *t, int n) {
char *c = Char(t);
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
c = strchr(c, '.');
@ -713,7 +713,7 @@ void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
}
/* Return base type of an array */
SwigType *SwigType_array_type(SwigType *ty) {
SwigType *SwigType_array_type(const SwigType *ty) {
SwigType *t;
t = Copy(ty);
while (SwigType_isarray(t)) {
@ -771,7 +771,7 @@ SwigType *SwigType_pop_function(SwigType *t) {
return g;
}
int SwigType_isfunction(SwigType *t) {
int SwigType_isfunction(const SwigType *t) {
char *c;
if (!t) {
return 0;
@ -793,7 +793,7 @@ int SwigType_isfunction(SwigType *t) {
/* Create a list of parameters from the type t, using the file_line_node Node for
* file and line numbering for the parameters */
ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node) {
ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node) {
List *l = SwigType_parmlist(t);
Hash *p, *pp = 0, *firstp = 0;
Iterator o;
@ -1094,7 +1094,7 @@ String *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(const SwigType *t) {
static Hash *memoize_stripped = 0;
SwigType *r;
List *l;
@ -1138,7 +1138,7 @@ SwigType *SwigType_strip_qualifiers(SwigType *t) {
* r.p.int => r.p.int
* ----------------------------------------------------------------------------- */
SwigType *SwigType_strip_single_qualifier(SwigType *t) {
SwigType *SwigType_strip_single_qualifier(const SwigType *t) {
static Hash *memoize_stripped = 0;
SwigType *r = 0;
List *l;

View file

@ -112,7 +112,7 @@ static Hash *typedef_resolve_cache = 0;
static Hash *typedef_all_cache = 0;
static Hash *typedef_qualified_cache = 0;
static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix);
static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix);
/* common attribute keys, to avoid calling find_key all the times */
@ -167,7 +167,7 @@ void SwigType_typesystem_init() {
* already defined.
* ----------------------------------------------------------------------------- */
int SwigType_typedef(SwigType *type, const_String_or_char_ptr name) {
int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name) {
if (Getattr(current_typetab, name))
return -1; /* Already defined */
if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */
@ -414,7 +414,7 @@ void SwigType_print_scope(Typetab *t) {
}
}
static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) {
Typetab *ss;
String *nnameprefix = 0;
static int check_parent = 1;
@ -806,7 +806,7 @@ return_result:
* Fully resolve a type down to its most basic datatype
* ----------------------------------------------------------------------------- */
SwigType *SwigType_typedef_resolve_all(SwigType *t) {
SwigType *SwigType_typedef_resolve_all(const SwigType *t) {
SwigType *n;
SwigType *r;
@ -848,7 +848,7 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
* scope, it is left in place.
* ----------------------------------------------------------------------------- */
SwigType *SwigType_typedef_qualified(SwigType *t) {
SwigType *SwigType_typedef_qualified(const SwigType *t) {
List *elements;
String *result;
int i, len;
@ -1049,7 +1049,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
* Checks a typename to see if it is a typedef.
* ----------------------------------------------------------------------------- */
int SwigType_istypedef(SwigType *t) {
int SwigType_istypedef(const SwigType *t) {
String *type;
type = SwigType_typedef_resolve(t);
@ -1150,7 +1150,7 @@ int SwigType_typedef_using(const_String_or_char_ptr name) {
* a class.
* ----------------------------------------------------------------------------- */
int SwigType_isclass(SwigType *t) {
int SwigType_isclass(const SwigType *t) {
SwigType *qty, *qtys;
int isclass = 0;
@ -1186,7 +1186,7 @@ int SwigType_isclass(SwigType *t) {
* everything is based on typemaps.
* ----------------------------------------------------------------------------- */
int SwigType_type(SwigType *t) {
int SwigType_type(const SwigType *t) {
char *c;
/* Check for the obvious stuff */
c = Char(t);
@ -1295,7 +1295,7 @@ int SwigType_type(SwigType *t) {
* %feature("valuewrapper").
* ----------------------------------------------------------------------------- */
SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
SwigType *SwigType_alttype(const SwigType *t, int local_tmap) {
Node *n;
SwigType *w = 0;
int use_wrapper = 0;
@ -1413,7 +1413,7 @@ static Hash *r_clientdata = 0; /* Hash mapping resolved types to client data
static Hash *r_mangleddata = 0; /* Hash mapping mangled types to client data */
static Hash *r_remembered = 0; /* Hash of types we remembered already */
static void (*r_tracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
static void (*r_tracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0;
void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata) {
if (!r_mangleddata) {
@ -1423,7 +1423,7 @@ void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr cli
}
void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata) {
void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata) {
String *mt;
SwigType *lt;
Hash *h;
@ -1536,12 +1536,12 @@ void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientda
}
}
void SwigType_remember(SwigType *ty) {
void SwigType_remember(const SwigType *ty) {
SwigType_remember_clientdata(ty, 0);
}
void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *) {
void (*o) (SwigType *, String *, String *) = r_tracefunc;
void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *) {
void (*o) (const SwigType *, String *, String *) = r_tracefunc;
r_tracefunc = tf;
return o;
}
@ -1713,7 +1713,7 @@ void SwigType_inherit(String *derived, String *base, String *cast, String *conve
* Determines if a t1 is a subtype of t2, ie, is t1 derived from t2
* ----------------------------------------------------------------------------- */
int SwigType_issubtype(SwigType *t1, SwigType *t2) {
int SwigType_issubtype(const SwigType *t1, const SwigType *t2) {
SwigType *ft1, *ft2;
String *b1, *b2;
Hash *h;