merge revisions 11877-12162 from trunk to gsoc2009-matevz
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12164 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
25ff4e4927
563 changed files with 22912 additions and 17189 deletions
|
|
@ -830,7 +830,7 @@ int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parm
|
|||
* Converts a C++ method node to a function accessor function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director) {
|
||||
int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director) {
|
||||
String *name, *qualifier;
|
||||
ParmList *parms;
|
||||
SwigType *type;
|
||||
|
|
@ -878,7 +878,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
These two lines just transfer the ownership of the 'this' pointer
|
||||
from the input to the output wrapping object.
|
||||
|
||||
This happens in python, but may also happens in other target
|
||||
This happens in python, but may also happen in other target
|
||||
languages.
|
||||
*/
|
||||
if (GetFlag(n, "feature:self:disown")) {
|
||||
|
|
@ -944,7 +944,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc
|
|||
String *defaultargs = Getattr(n, "defaultargs");
|
||||
String *code = Getattr(n, "code");
|
||||
String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
|
||||
String *membername = Swig_name_member(cname, name);
|
||||
String *membername = Swig_name_member(nspace, cname, name);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
int is_smart_pointer = flags & CWRAP_SMART_POINTER;
|
||||
|
||||
|
|
@ -1057,7 +1057,7 @@ Node *Swig_directormap(Node *module, String *type) {
|
|||
* This function creates a C wrapper for a C constructor function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags) {
|
||||
int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags) {
|
||||
ParmList *parms;
|
||||
Parm *prefix_args;
|
||||
Parm *p;
|
||||
|
|
@ -1097,7 +1097,7 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis
|
|||
String *cres;
|
||||
String *defaultargs = Getattr(n, "defaultargs");
|
||||
String *code = Getattr(n, "code");
|
||||
String *membername = Swig_name_construct(classname);
|
||||
String *membername = Swig_name_construct(nspace, classname);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
|
||||
/* Check if the constructor is overloaded. If so, and it has code attached, we append an extra suffix
|
||||
|
|
@ -1201,7 +1201,7 @@ int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparis
|
|||
* This function creates a C wrapper for a destructor function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags) {
|
||||
int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int cplus, int flags) {
|
||||
SwigType *type;
|
||||
Parm *p;
|
||||
|
||||
|
|
@ -1218,7 +1218,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags)
|
|||
String *cres;
|
||||
String *call;
|
||||
String *membername, *mangled, *code;
|
||||
membername = Swig_name_destroy(classname);
|
||||
membername = Swig_name_destroy(nspace, classname);
|
||||
mangled = Swig_name_mangle(membername);
|
||||
code = Getattr(n, "code");
|
||||
if (code) {
|
||||
|
|
@ -1267,10 +1267,7 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
SwigType *ty;
|
||||
SwigType *type;
|
||||
SwigType *void_type = NewString("void");
|
||||
String *membername;
|
||||
String *mangled;
|
||||
String *self = 0;
|
||||
String *sname;
|
||||
|
||||
int varcref = flags & CWRAP_NATURAL_VAR;
|
||||
|
||||
|
|
@ -1284,10 +1281,6 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
name = Getattr(n, "name");
|
||||
type = Getattr(n, "type");
|
||||
|
||||
sname = Swig_name_set(name);
|
||||
membername = Swig_name_member(classname, sname);
|
||||
mangled = Swig_name_mangle(membername);
|
||||
|
||||
t = NewString(classname);
|
||||
SwigType_add_pointer(t);
|
||||
parms = NewParm(t, "self", n);
|
||||
|
|
@ -1310,6 +1303,11 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
String *call;
|
||||
String *cres;
|
||||
String *code = Getattr(n, "code");
|
||||
|
||||
String *sname = Swig_name_set(0, name);
|
||||
String *membername = Swig_name_member(0, classname, sname);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
|
||||
if (code) {
|
||||
/* I don't think this ever gets run - WSF */
|
||||
Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self");
|
||||
|
|
@ -1317,8 +1315,12 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
call = Swig_cfunction_call(mangled, parms);
|
||||
cres = NewStringf("%s;", call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(call);
|
||||
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
Delete(mangled);
|
||||
Delete(membername);
|
||||
Delete(sname);
|
||||
} else {
|
||||
String *call = Swig_cmemberset_call(name, type, self, varcref);
|
||||
String *cres = NewStringf("%s;", call);
|
||||
|
|
@ -1331,9 +1333,6 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
|||
Delete(parms);
|
||||
Delete(ty);
|
||||
Delete(void_type);
|
||||
Delete(membername);
|
||||
Delete(sname);
|
||||
Delete(mangled);
|
||||
Delete(self);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1350,10 +1349,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
SwigType *t;
|
||||
SwigType *ty;
|
||||
SwigType *type;
|
||||
String *membername;
|
||||
String *mangled;
|
||||
String *self = 0;
|
||||
String *gname;
|
||||
|
||||
int varcref = flags & CWRAP_NATURAL_VAR;
|
||||
|
||||
|
|
@ -1373,10 +1369,6 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
name = Getattr(n, "name");
|
||||
type = Getattr(n, "type");
|
||||
|
||||
gname = Swig_name_get(name);
|
||||
membername = Swig_name_member(classname, gname);
|
||||
mangled = Swig_name_mangle(membername);
|
||||
|
||||
t = NewString(classname);
|
||||
SwigType_add_pointer(t);
|
||||
parms = NewParm(t, "self", n);
|
||||
|
|
@ -1388,8 +1380,12 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
if (flags & CWRAP_EXTEND) {
|
||||
String *call;
|
||||
String *cres;
|
||||
|
||||
String *code = Getattr(n, "code");
|
||||
|
||||
String *gname = Swig_name_get(0, name);
|
||||
String *membername = Swig_name_member(0, classname, gname);
|
||||
String *mangled = Swig_name_mangle(membername);
|
||||
|
||||
if (code) {
|
||||
/* I don't think this ever gets run - WSF */
|
||||
Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, "self");
|
||||
|
|
@ -1397,8 +1393,12 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
call = Swig_cfunction_call(mangled, parms);
|
||||
cres = Swig_cresult(ty, "result", call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
Delete(mangled);
|
||||
Delete(membername);
|
||||
Delete(gname);
|
||||
} else {
|
||||
String *call = Swig_cmemberget_call(name, type, self, varcref);
|
||||
String *cres = Swig_cresult(ty, "result", call);
|
||||
|
|
@ -1410,9 +1410,6 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
Setattr(n, "parms", parms);
|
||||
Delete(parms);
|
||||
Delete(ty);
|
||||
Delete(membername);
|
||||
Delete(gname);
|
||||
Delete(mangled);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1438,7 +1435,7 @@ int Swig_VarsetToFunction(Node *n, int flags) {
|
|||
parms = NewParm(ty, name, n);
|
||||
|
||||
if (flags & CWRAP_EXTEND) {
|
||||
String *sname = Swig_name_set(name);
|
||||
String *sname = Swig_name_set(0, name);
|
||||
String *mangled = Swig_name_mangle(sname);
|
||||
String *call = Swig_cfunction_call(mangled, parms);
|
||||
String *cres = NewStringf("%s;", call);
|
||||
|
|
@ -1492,7 +1489,7 @@ int Swig_VargetToFunction(Node *n, int flags) {
|
|||
ty = Swig_wrapped_var_type(type, varcref);
|
||||
|
||||
if (flags & CWRAP_EXTEND) {
|
||||
String *sname = Swig_name_get(name);
|
||||
String *sname = Swig_name_get(0, name);
|
||||
String *mangled = Swig_name_mangle(sname);
|
||||
call = Swig_cfunction_call(mangled, 0);
|
||||
cres = Swig_cresult(ty, "result", call);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,15 @@ char cvsroot_misc_c[] = "$Id$";
|
|||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static char *fake_version = 0;
|
||||
|
||||
|
|
@ -135,11 +144,79 @@ String *Swig_strip_c_comments(const String *s) {
|
|||
return stripped;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* is_directory()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static int is_directory(String *directory) {
|
||||
int last = Len(directory) - 1;
|
||||
int statres;
|
||||
struct stat st;
|
||||
char *dir = Char(directory);
|
||||
if (dir[last] == SWIG_FILE_DELIMITER[0]) {
|
||||
/* remove trailing slash - can cause S_ISDIR to fail on Windows, at least */
|
||||
dir[last] = 0;
|
||||
statres = stat(dir, &st);
|
||||
dir[last] = SWIG_FILE_DELIMITER[0];
|
||||
} else {
|
||||
statres = stat(dir, &st);
|
||||
}
|
||||
return (statres == 0 && S_ISDIR(st.st_mode));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_new_subdirectory()
|
||||
*
|
||||
* Create the subdirectory only if the basedirectory already exists as a directory.
|
||||
* basedirectory can be NULL or empty to indicate current directory.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) {
|
||||
String *error = 0;
|
||||
struct stat st;
|
||||
int current_directory = basedirectory ? (Len(basedirectory) == 0 ? 1 : 0) : 0;
|
||||
|
||||
if (current_directory || is_directory(basedirectory)) {
|
||||
Iterator it;
|
||||
String *dir = basedirectory ? NewString(basedirectory) : NewString("");
|
||||
List *subdirs = Split(subdirectory, SWIG_FILE_DELIMITER[0], INT_MAX);
|
||||
|
||||
for (it = First(subdirs); it.item; it = Next(it)) {
|
||||
int statdir;
|
||||
String *subdirectory = it.item;
|
||||
Printf(dir, "%s", subdirectory);
|
||||
statdir = stat(Char(dir), &st);
|
||||
if (statdir == 0) {
|
||||
Printf(dir, SWIG_FILE_DELIMITER);
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
continue;
|
||||
} else {
|
||||
error = NewStringf("Cannot create directory %s", dir);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
int result = _mkdir(Char(dir));
|
||||
#else
|
||||
int result = mkdir(Char(dir), 0777);
|
||||
#endif
|
||||
Printf(dir, SWIG_FILE_DELIMITER);
|
||||
if (result != 0 && errno != EEXIST) {
|
||||
error = NewStringf("Cannot create directory %s", dir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
error = NewStringf("Cannot create subdirectory %s under the base directory %s. Either the base does not exist as a directory or it is not readable.", subdirectory, basedirectory);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_filename_correct()
|
||||
*
|
||||
* Corrects filenames on non-unix systems
|
||||
* Corrects filename paths by removing duplicate delimeters and on non-unix
|
||||
* systems use the correct delimeter across the whole name.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_filename_correct(String *filename) {
|
||||
|
|
@ -152,6 +229,9 @@ void Swig_filename_correct(String *filename) {
|
|||
/* accept Windows path separator in addition to Unix path separator */
|
||||
Replaceall(filename, "\\", SWIG_FILE_DELIMITER);
|
||||
#endif
|
||||
/* remove all duplicate file name delimiters */
|
||||
while (Replaceall(filename, SWIG_FILE_DELIMITER SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER)) {
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -163,7 +243,9 @@ void Swig_filename_correct(String *filename) {
|
|||
String *Swig_filename_escape(String *filename) {
|
||||
String *adjusted_filename = Copy(filename);
|
||||
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
|
||||
Replaceall(adjusted_filename, "\\\\", "\\"); /* remove double '\' in case any already present */
|
||||
/* remove all double '\' in case any already present */
|
||||
while (Replaceall(adjusted_filename, "\\\\", "\\")) {
|
||||
}
|
||||
Replaceall(adjusted_filename, "\\", "\\\\");
|
||||
#endif
|
||||
return adjusted_filename;
|
||||
|
|
@ -1010,7 +1092,7 @@ String *Swig_string_strip(String *s) {
|
|||
} else {
|
||||
const char *cs = Char(s);
|
||||
const char *ce = Strchr(cs, ']');
|
||||
if (*cs != '[' || ce == NULL) {
|
||||
if (*cs != '[' || !ce) {
|
||||
ns = NewString(s);
|
||||
} else {
|
||||
String *fmt = NewStringf("%%.%ds", ce-cs-1);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,15 @@
|
|||
* naming.c
|
||||
*
|
||||
* Functions for generating various kinds of names during code generation.
|
||||
*
|
||||
* Swig_name_register is used to register a format string for generating names.
|
||||
* The format string makes use of the following format specifiers:
|
||||
*
|
||||
* %c - class name is substituted
|
||||
* %f - function name is substituted
|
||||
* %m - member name is substituted
|
||||
* %n - namespace is substituted
|
||||
* %v - variable name is substituted
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_naming_c[] = "$Id$";
|
||||
|
|
@ -125,6 +134,23 @@ static int name_mangle(String *r) {
|
|||
return special;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* replace_nspace()
|
||||
*
|
||||
* Mangles in the namespace from nspace by replacing %n in name if nspace feature required.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void replace_nspace(String *name, const_String_or_char_ptr nspace) {
|
||||
if (nspace) {
|
||||
String *namspace = NewStringf("%s_", nspace);
|
||||
Replaceall(namspace, NSPACE_SEPARATOR, "_");
|
||||
Replace(name, "%n", namspace, DOH_REPLACE_ANY);
|
||||
Delete(namspace);
|
||||
} else {
|
||||
Replace(name, "%n", "", DOH_REPLACE_ANY);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_name_mangle()
|
||||
*
|
||||
|
|
@ -172,7 +198,7 @@ String *Swig_name_wrapper(const_String_or_char_ptr fname) {
|
|||
* Returns the name of a class method.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname) {
|
||||
String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -184,7 +210,7 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "member");
|
||||
if (!f) {
|
||||
Append(r, "%c_%m");
|
||||
Append(r, "%n%c_%m");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -192,8 +218,9 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Replace(r, "%m", mname, DOH_REPLACE_ANY);
|
||||
Replace(r, "%m", membername, DOH_REPLACE_ANY);
|
||||
/* name_mangle(r); */
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -205,7 +232,7 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha
|
|||
* Returns the name of the accessor function used to get a variable.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_get(const_String_or_char_ptr vname) {
|
||||
String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname) {
|
||||
String *r;
|
||||
String *f;
|
||||
|
||||
|
|
@ -218,10 +245,12 @@ String *Swig_name_get(const_String_or_char_ptr vname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "get");
|
||||
if (!f) {
|
||||
Append(r, "%v_get");
|
||||
Append(r, "%n%v_get");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%v", vname, DOH_REPLACE_ANY);
|
||||
/* name_mangle(r); */
|
||||
return r;
|
||||
|
|
@ -233,7 +262,7 @@ String *Swig_name_get(const_String_or_char_ptr vname) {
|
|||
* Returns the name of the accessor function used to set a variable.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_set(const_String_or_char_ptr vname) {
|
||||
String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname) {
|
||||
String *r;
|
||||
String *f;
|
||||
|
||||
|
|
@ -242,10 +271,12 @@ String *Swig_name_set(const_String_or_char_ptr vname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "set");
|
||||
if (!f) {
|
||||
Append(r, "%v_set");
|
||||
Append(r, "%n%v_set");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%v", vname, DOH_REPLACE_ANY);
|
||||
/* name_mangle(r); */
|
||||
return r;
|
||||
|
|
@ -257,7 +288,7 @@ String *Swig_name_set(const_String_or_char_ptr vname) {
|
|||
* Returns the name of the accessor function used to create an object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_construct(const_String_or_char_ptr classname) {
|
||||
String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -269,7 +300,7 @@ String *Swig_name_construct(const_String_or_char_ptr classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "construct");
|
||||
if (!f) {
|
||||
Append(r, "new_%c");
|
||||
Append(r, "new_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -278,6 +309,8 @@ String *Swig_name_construct(const_String_or_char_ptr classname) {
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -290,7 +323,7 @@ String *Swig_name_construct(const_String_or_char_ptr classname) {
|
|||
* Returns the name of the accessor function used to copy an object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
|
||||
String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -302,7 +335,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "copy");
|
||||
if (!f) {
|
||||
Append(r, "copy_%c");
|
||||
Append(r, "copy_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -312,6 +345,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
|
|||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -323,7 +357,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
|
|||
* Returns the name of the accessor function used to destroy an object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_destroy(const_String_or_char_ptr classname) {
|
||||
String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -334,7 +368,7 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "destroy");
|
||||
if (!f) {
|
||||
Append(r, "delete_%c");
|
||||
Append(r, "delete_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -343,6 +377,8 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) {
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
@ -355,7 +391,7 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) {
|
|||
* Returns the name of the accessor function used to disown an object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_disown(const_String_or_char_ptr classname) {
|
||||
String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
|
||||
String *r;
|
||||
String *f;
|
||||
String *rclassname;
|
||||
|
|
@ -366,7 +402,7 @@ String *Swig_name_disown(const_String_or_char_ptr classname) {
|
|||
naming_hash = NewHash();
|
||||
f = Getattr(naming_hash, "disown");
|
||||
if (!f) {
|
||||
Append(r, "disown_%c");
|
||||
Append(r, "disown_%n%c");
|
||||
} else {
|
||||
Append(r, f);
|
||||
}
|
||||
|
|
@ -375,6 +411,8 @@ String *Swig_name_disown(const_String_or_char_ptr classname) {
|
|||
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
|
||||
cname = strchr(cname, ' ') + 1;
|
||||
}
|
||||
|
||||
replace_nspace(r, nspace);
|
||||
Replace(r, "%c", cname, DOH_REPLACE_ANY);
|
||||
Delete(rclassname);
|
||||
return r;
|
||||
|
|
|
|||
|
|
@ -1390,6 +1390,10 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
state = 11;
|
||||
else if (c == '*')
|
||||
state = 12;
|
||||
else if (c == startchar) {
|
||||
state = 0;
|
||||
num_levels++;
|
||||
}
|
||||
else
|
||||
state = 0;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -279,233 +279,187 @@ int SwigType_issimple(SwigType *t) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_default()
|
||||
* SwigType_default_create()
|
||||
*
|
||||
* Create the default string for this datatype. This takes a type and strips it
|
||||
* down to its most primitive form--resolving all typedefs and removing operators.
|
||||
* Create the default type for this datatype. This takes a type and strips it
|
||||
* down to a generic form first by resolving all typedefs.
|
||||
*
|
||||
* Rules:
|
||||
* Pointers: p.SWIGTYPE
|
||||
* References: r.SWIGTYPE
|
||||
* Arrays: a().SWIGTYPE
|
||||
* Types: SWIGTYPE
|
||||
* MemberPointer: m(CLASS).SWIGTYPE
|
||||
* Enums: enum SWIGTYPE
|
||||
* Pointers: p.SWIGTYPE
|
||||
* References: r.SWIGTYPE
|
||||
* Arrays no dimension: a().SWIGTYPE
|
||||
* Arrays with dimension: a(ANY).SWIGTYPE
|
||||
* Member pointer: m(CLASS).SWIGTYPE
|
||||
* Function pointer: f(ANY).SWIGTYPE
|
||||
* Enums: enum SWIGTYPE
|
||||
* Types: SWIGTYPE
|
||||
*
|
||||
* Note: if this function is applied to a primitive type, it returns NULL. This
|
||||
* allows recursive application for special types like arrays.
|
||||
* Examples (also see SwigType_default_deduce):
|
||||
*
|
||||
* int [2][4]
|
||||
* a(2).a(4).int
|
||||
* a(ANY).a(ANY).SWIGTYPE
|
||||
*
|
||||
* struct A {};
|
||||
* typedef A *Aptr;
|
||||
* Aptr const &
|
||||
* r.q(const).Aptr
|
||||
* r.q(const).p.SWIGTYPE
|
||||
*
|
||||
* enum E {e1, e2};
|
||||
* enum E const &
|
||||
* r.q(const).enum E
|
||||
* r.q(const).enum SWIGTYPE
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
static Hash *default_cache = 0;
|
||||
#endif
|
||||
SwigType *SwigType_default_create(SwigType *ty) {
|
||||
SwigType *r = 0;
|
||||
List *l;
|
||||
Iterator it;
|
||||
int numitems;
|
||||
|
||||
#define SWIG_NEW_TYPE_DEFAULT
|
||||
/* The new default type resolution method:
|
||||
if (!SwigType_isvarargs(ty)) {
|
||||
SwigType *t = SwigType_typedef_resolve_all(ty);
|
||||
r = NewStringEmpty();
|
||||
l = SwigType_split(t);
|
||||
numitems = Len(l);
|
||||
|
||||
1.- It preserves the original mixed types, then it goes 'backward'
|
||||
first deleting the qualifier, then the inner types
|
||||
|
||||
typedef A *Aptr;
|
||||
const Aptr&;
|
||||
r.q(const).Aptr -> r.q(const).p.SWIGTYPE
|
||||
r.q(const).p.SWIGTYPE -> r.p.SWIGTYPE
|
||||
r.p.SWIGTYPE -> r.SWIGTYPE
|
||||
r.SWIGTYPE -> SWIGTYPE
|
||||
if (numitems >= 1) {
|
||||
String *last_subtype = Getitem(l, numitems-1);
|
||||
if (SwigType_isenum(last_subtype))
|
||||
Setitem(l, numitems-1, NewString("enum SWIGTYPE"));
|
||||
else
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
}
|
||||
|
||||
for (it = First(l); it.item; it = Next(it)) {
|
||||
String *subtype = it.item;
|
||||
if (SwigType_isarray(subtype)) {
|
||||
if (Equal(subtype, "a()."))
|
||||
Append(r, NewString("a()."));
|
||||
else
|
||||
Append(r, NewString("a(ANY)."));
|
||||
} else if (SwigType_isfunction(subtype)) {
|
||||
Append(r, NewString("f(ANY).SWIGTYPE"));
|
||||
break;
|
||||
} else if (SwigType_ismemberpointer(subtype)) {
|
||||
Append(r, NewString("m(CLASS).SWIGTYPE"));
|
||||
break;
|
||||
} else {
|
||||
Append(r, subtype);
|
||||
}
|
||||
}
|
||||
|
||||
enum Hello {};
|
||||
const Hello& hi;
|
||||
r.q(const).Hello -> r.q(const).enum SWIGTYPE
|
||||
r.q(const).enum SWIGTYPE -> r.enum SWIGTYPE
|
||||
r.enum SWIGTYPE -> r.SWIGTYPE
|
||||
r.SWIGTYPE -> SWIGTYPE
|
||||
Delete(l);
|
||||
Delete(t);
|
||||
}
|
||||
|
||||
int a[2][4];
|
||||
a(2).a(4).int -> a(ANY).a(ANY).SWIGTYPE
|
||||
a(ANY).a(ANY).SWIGTYPE -> a(ANY).a().SWIGTYPE
|
||||
a(ANY).a().SWIGTYPE -> a(ANY).p.SWIGTYPE
|
||||
a(ANY).p.SWIGTYPE -> a(ANY).SWIGTYPE
|
||||
a(ANY).SWIGTYPE -> a().SWIGTYPE
|
||||
a().SWIGTYPE -> p.SWIGTYPE
|
||||
p.SWIGTYPE -> SWIGTYPE
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
static
|
||||
void SwigType_add_default(String *def, SwigType *nr) {
|
||||
if (Strcmp(nr, "SWIGTYPE") == 0) {
|
||||
Append(def, "SWIGTYPE");
|
||||
} else {
|
||||
String *q = SwigType_isqualifier(nr) ? SwigType_pop(nr) : 0;
|
||||
if (q && strstr(Char(nr), "SWIGTYPE")) {
|
||||
Append(def, nr);
|
||||
} else {
|
||||
String *nd = SwigType_default(nr);
|
||||
if (nd) {
|
||||
String *bdef = nd;
|
||||
if (q) {
|
||||
bdef = NewStringf("%s%s", q, nd);
|
||||
if ((Strcmp(nr, bdef) == 0)) {
|
||||
Delete(bdef);
|
||||
bdef = nd;
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_default_deduce()
|
||||
*
|
||||
* This function implements type deduction used in the typemap matching rules
|
||||
* and is very close to the type deduction used in partial template class
|
||||
* specialization matching in that the most specialized type is always chosen.
|
||||
* SWIGTYPE is used as the generic type. The basic idea is to repeatedly call
|
||||
* this function to find a deduced type unless until nothing matches.
|
||||
*
|
||||
* The type t must have already been converted to the default type via a call to
|
||||
* SwigType_default_create() before calling this function.
|
||||
*
|
||||
* Example deductions (matching the examples described in SwigType_default_create),
|
||||
* where the the most specialized matches are highest in the list:
|
||||
*
|
||||
* a(ANY).a(ANY).SWIGTYPE
|
||||
* a(ANY).a().SWIGTYPE
|
||||
* a(ANY).p.SWIGTYPE
|
||||
* a(ANY).SWIGTYPE
|
||||
* a().SWIGTYPE
|
||||
* p.SWIGTYPE
|
||||
* SWIGTYPE
|
||||
*
|
||||
* r.q(const).p.SWIGTYPE
|
||||
* r.q(const).SWIGTYPE
|
||||
* r.SWIGTYPE
|
||||
* SWIGTYPE
|
||||
*
|
||||
* r.q(const).enum SWIGTYPE
|
||||
* r.enum SWIGTYPE
|
||||
* r.SWIGTYPE
|
||||
* SWIGTYPE
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_default_deduce(SwigType *t) {
|
||||
SwigType *r = NewStringEmpty();
|
||||
List *l;
|
||||
Iterator it;
|
||||
int numitems;
|
||||
|
||||
l = SwigType_split(t);
|
||||
|
||||
numitems = Len(l);
|
||||
if (numitems >= 1) {
|
||||
String *last_subtype = Getitem(l, numitems-1);
|
||||
int is_enum = SwigType_isenum(last_subtype);
|
||||
|
||||
if (numitems >=2 ) {
|
||||
String *subtype = Getitem(l, numitems-2); /* last but one */
|
||||
if (SwigType_isarray(subtype)) {
|
||||
if (is_enum) {
|
||||
/* enum deduction, enum SWIGTYPE => SWIGTYPE */
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
} else {
|
||||
/* array deduction, a(ANY). => a(). => p. */
|
||||
String *deduced_subtype = 0;
|
||||
if (Strcmp(subtype, "a().") == 0) {
|
||||
deduced_subtype = NewString("p.");
|
||||
} else if (Strcmp(subtype, "a(ANY).") == 0) {
|
||||
deduced_subtype = NewString("a().");
|
||||
} else {
|
||||
Delete(nd);
|
||||
assert(0);
|
||||
}
|
||||
Setitem(l, numitems-2, deduced_subtype);
|
||||
}
|
||||
Append(def, bdef);
|
||||
Delete(bdef);
|
||||
} else if (SwigType_ismemberpointer(subtype)) {
|
||||
/* member pointer deduction, m(CLASS). => p. */
|
||||
Setitem(l, numitems-2, NewString("p."));
|
||||
} else if (is_enum && !SwigType_isqualifier(subtype)) {
|
||||
/* enum deduction, enum SWIGTYPE => SWIGTYPE */
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
} else {
|
||||
Append(def, nr);
|
||||
/* simple type deduction, eg, r.p.p. => r.p. */
|
||||
/* also function pointers eg, p.f(ANY). => p. */
|
||||
Delitem(l, numitems-2);
|
||||
}
|
||||
}
|
||||
Delete(q);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SwigType *SwigType_default(SwigType *t) {
|
||||
String *r1, *def;
|
||||
String *r = 0;
|
||||
char *cr;
|
||||
|
||||
#ifdef SWIG_DEFAULT_CACHE
|
||||
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);
|
||||
r = r1;
|
||||
}
|
||||
if (SwigType_isqualifier(r)) {
|
||||
String *q;
|
||||
if (r == t)
|
||||
r = Copy(t);
|
||||
q = SwigType_pop(r);
|
||||
if (strstr(Char(r), "SWIGTYPE")) {
|
||||
Delete(q);
|
||||
def = r;
|
||||
return def;
|
||||
}
|
||||
Delete(q);
|
||||
}
|
||||
cr = Char(r);
|
||||
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.");
|
||||
SwigType_add_default(def, nr);
|
||||
Delete(nr);
|
||||
#else
|
||||
def = NewString("p.SWIGTYPE");
|
||||
#endif
|
||||
} else if (strcmp(cr, "r.SWIGTYPE") == 0) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else if (SwigType_isreference(r)) {
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType *nr = Copy(r);
|
||||
SwigType_del_reference(nr);
|
||||
def = NewString("r.");
|
||||
SwigType_add_default(def, nr);
|
||||
Delete(nr);
|
||||
#else
|
||||
def = NewString("r.SWIGTYPE");
|
||||
#endif
|
||||
} else if (SwigType_isrvalue_reference(r)) {
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType *nr = Copy(r);
|
||||
SwigType_del_rvalue_reference(nr);
|
||||
def = NewString("z.");
|
||||
SwigType_add_default(def, nr);
|
||||
Delete(nr);
|
||||
#else
|
||||
def = NewString("z.SWIGTYPE");
|
||||
#endif
|
||||
} else if (SwigType_isarray(r)) {
|
||||
if (strcmp(cr, "a().SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} 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);
|
||||
if (!Len(dim)) {
|
||||
char *c = Char(nr);
|
||||
empty = strstr(c, "a(ANY).") != c;
|
||||
}
|
||||
Delete(dim);
|
||||
}
|
||||
if (empty) {
|
||||
def = NewString("a().");
|
||||
if (is_enum) {
|
||||
/* enum deduction, enum SWIGTYPE => SWIGTYPE */
|
||||
Setitem(l, numitems-1, NewString("SWIGTYPE"));
|
||||
} else {
|
||||
def = NewString("a(ANY).");
|
||||
/* delete the only item, we are done with deduction */
|
||||
Delitem(l, 0);
|
||||
}
|
||||
#ifdef SWIG_NEW_TYPE_DEFAULT
|
||||
SwigType_del_array(nr);
|
||||
SwigType_add_default(def, nr);
|
||||
#else
|
||||
Append(def, "SWIGTYPE");
|
||||
#endif
|
||||
Delete(nr);
|
||||
}
|
||||
} else if (SwigType_ismemberpointer(r)) {
|
||||
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) {
|
||||
def = NewString("SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("enum SWIGTYPE");
|
||||
}
|
||||
} else if (SwigType_isfunction(r)) {
|
||||
if (strcmp(cr, "f(ANY).SWIGTYPE") == 0) {
|
||||
def = NewString("p.SWIGTYPE");
|
||||
} else {
|
||||
def = NewString("p.f(ANY).SWIGTYPE");
|
||||
}
|
||||
} else {
|
||||
def = NewString("SWIGTYPE");
|
||||
assert(0);
|
||||
}
|
||||
if (r != t)
|
||||
|
||||
for (it = First(l); it.item; it = Next(it)) {
|
||||
Append(r, it.item);
|
||||
}
|
||||
|
||||
if (Len(r) == 0) {
|
||||
Delete(r);
|
||||
if (Equal(def, t)) {
|
||||
Delete(def);
|
||||
def = 0;
|
||||
r = 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);
|
||||
Delete(cdef);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Printf(stderr,"type : def %s : %s\n", t, def); */
|
||||
|
||||
return def;
|
||||
Delete(l);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_namestr()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Header file for the SWIG core.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SWIGCORE_H_
|
||||
#define SWIGCORE_H_
|
||||
|
||||
|
|
@ -37,6 +35,10 @@ extern "C" {
|
|||
#define SWIG_ERROR 0
|
||||
#define SWIG_NOWRAP 0
|
||||
|
||||
/* Global macros */
|
||||
#define NSPACE_SEPARATOR "." /* Namespace separator for the nspace feature - this should be changed to a target language configurable variable */
|
||||
#define NSPACE_TODO 0 /* Languages that still need to implement and test the nspace feature use this */
|
||||
|
||||
/* Short names for common data types */
|
||||
|
||||
typedef DOH String;
|
||||
|
|
@ -162,6 +164,7 @@ extern "C" {
|
|||
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 SwigType *SwigType_functionpointer_decompose(SwigType *t);
|
||||
extern String *SwigType_base(const SwigType *t);
|
||||
extern String *SwigType_namestr(const SwigType *t);
|
||||
|
|
@ -175,6 +178,8 @@ extern "C" {
|
|||
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 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);
|
||||
|
|
@ -219,6 +224,7 @@ extern "C" {
|
|||
extern void Swig_symbol_setscopename(const_String_or_char_ptr name);
|
||||
extern String *Swig_symbol_getscopename(void);
|
||||
extern String *Swig_symbol_qualifiedscopename(Symtab *symtab);
|
||||
extern String *Swig_symbol_qualified_language_scopename(Symtab *symtab);
|
||||
extern Symtab *Swig_symbol_newscope(void);
|
||||
extern Symtab *Swig_symbol_setscope(Symtab *);
|
||||
extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname);
|
||||
|
|
@ -266,13 +272,13 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern void Swig_name_unregister(const_String_or_char_ptr method);
|
||||
extern String *Swig_name_mangle(const_String_or_char_ptr s);
|
||||
extern String *Swig_name_wrapper(const_String_or_char_ptr fname);
|
||||
extern String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname);
|
||||
extern String *Swig_name_get(const_String_or_char_ptr vname);
|
||||
extern String *Swig_name_set(const_String_or_char_ptr vname);
|
||||
extern String *Swig_name_construct(const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_copyconstructor(const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_destroy(const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_disown(const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_member(const_String_or_char_ptr nspace, const_String_or_char_ptr classname, const_String_or_char_ptr membername);
|
||||
extern String *Swig_name_get(const_String_or_char_ptr nspace, const_String_or_char_ptr vname);
|
||||
extern String *Swig_name_set(const_String_or_char_ptr nspace, const_String_or_char_ptr vname);
|
||||
extern String *Swig_name_construct(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_copyconstructor(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
extern String *Swig_name_disown(const_String_or_char_ptr nspace, const_String_or_char_ptr classname);
|
||||
|
||||
extern void Swig_naming_init(void);
|
||||
extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
|
||||
|
|
@ -303,6 +309,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern void Swig_banner(File *f);
|
||||
extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar);
|
||||
extern String *Swig_strip_c_comments(const String *s);
|
||||
extern String *Swig_new_subdirectory(String *basedirectory, String *subdirectory);
|
||||
extern void Swig_filename_correct(String *filename);
|
||||
extern String *Swig_filename_escape(String *filename);
|
||||
extern void Swig_filename_unescape(String *filename);
|
||||
|
|
@ -353,9 +360,9 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
|
||||
/* --- 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_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director);
|
||||
extern int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
|
||||
extern int Swig_DestructorToFunction(Node *n, const_String_or_char_ptr nspace, 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);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* File handling functions in the SWIG core
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9603 2006-12-05 21:47:01Z beazley $ */
|
||||
|
||||
extern List *Swig_add_directory(const_String_or_char_ptr dirname);
|
||||
extern void Swig_push_directory(const_String_or_char_ptr dirname);
|
||||
extern void Swig_pop_directory(void);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Header file for the SWIG command line processing functions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9622 2006-12-19 03:49:17Z beazley $ */
|
||||
|
||||
extern void Swig_init_args(int argc, char **argv);
|
||||
extern void Swig_mark_arg(int n);
|
||||
extern int Swig_check_marked(int n);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* parameter lists.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9629 2006-12-30 18:27:47Z beazley $ */
|
||||
|
||||
/* Individual parameters */
|
||||
extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *file_line_node);
|
||||
extern Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* C/C++ scanner.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9633 2007-01-10 23:43:07Z beazley $ */
|
||||
|
||||
typedef struct Scanner Scanner;
|
||||
|
||||
extern Scanner *NewScanner(void);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
* and function names are meant to be similar.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9622 2006-12-19 03:49:17Z beazley $ */
|
||||
|
||||
/* Macros to traverse the DOM tree */
|
||||
|
||||
#define nodeType(x) Getattr(x,"nodeType")
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Functions related to wrapper objects.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* $Id: swig.h 9635 2007-01-12 01:44:16Z beazley $ */
|
||||
|
||||
typedef struct Wrapper {
|
||||
Hash *localh;
|
||||
String *def;
|
||||
|
|
|
|||
|
|
@ -353,6 +353,21 @@ String *Swig_symbol_qualifiedscopename(Symtab *symtab) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_qualified_language_scopename()
|
||||
*
|
||||
* Get the fully qualified C scopename of a symbol table but using a language
|
||||
* specific separator for the scopenames. Basically the same as
|
||||
* Swig_symbol_qualifiedscopename() but using the different separator.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_symbol_qualified_language_scopename(Symtab *n) {
|
||||
/* TODO: fix for %rename to work */
|
||||
String *result = Swig_symbol_qualifiedscopename(n);
|
||||
Replaceall(result, "::", NSPACE_SEPARATOR);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_newscope()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -674,7 +674,7 @@ static Hash *typemap_search_helper(int debug_display, Hash *tm, const String *tm
|
|||
if (debug_display)
|
||||
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, 0));
|
||||
if (tm) {
|
||||
result = Getattr(tm, tm_method); /* See if there is simply a type match */
|
||||
result = Getattr(tm, tm_method); /* See if there is simply a type without name match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
|
|
@ -698,11 +698,11 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
|||
Hash *backup = 0;
|
||||
SwigType *primitive = 0;
|
||||
SwigType *ctype = 0;
|
||||
SwigType *ctype_unstripped = 0;
|
||||
int ts;
|
||||
int isarray;
|
||||
const String *cname = 0;
|
||||
const String *cqualifiedname = 0;
|
||||
SwigType *unstripped = 0;
|
||||
String *tm_method = typemap_method_name(tmap_method);
|
||||
int debug_display = (in_typemap_search_multi == 0) && typemap_search_debug;
|
||||
|
||||
|
|
@ -718,12 +718,13 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
|||
Delete(typestr);
|
||||
}
|
||||
while (ts >= 0) {
|
||||
ctype = type;
|
||||
ctype = Copy(type);
|
||||
ctype_unstripped = Copy(ctype);
|
||||
while (ctype) {
|
||||
/* Try to get an exact type-match */
|
||||
tm = get_typemap(ts, ctype);
|
||||
result = typemap_search_helper(debug_display, tm, tm_method, ctype, cqualifiedname, cname, &backup);
|
||||
if (result)
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
|
||||
{
|
||||
|
|
@ -733,7 +734,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
|||
tm = get_typemap(ts, template_prefix);
|
||||
result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup);
|
||||
Delete(template_prefix);
|
||||
if (result)
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
}
|
||||
}
|
||||
|
|
@ -747,47 +748,43 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
|||
tm = get_typemap(ts, noarrays);
|
||||
result = typemap_search_helper(debug_display, tm, tm_method, noarrays, cqualifiedname, cname, &backup);
|
||||
Delete(noarrays);
|
||||
if (result)
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
}
|
||||
|
||||
/* No match so far. If the type is unstripped, we'll strip its
|
||||
qualifiers and check. Otherwise, we'll try to resolve a typedef */
|
||||
|
||||
if (!unstripped) {
|
||||
unstripped = ctype;
|
||||
ctype = SwigType_strip_qualifiers(ctype);
|
||||
if (!Equal(ctype, unstripped))
|
||||
continue; /* Types are different */
|
||||
Delete(ctype);
|
||||
ctype = unstripped;
|
||||
unstripped = 0;
|
||||
}
|
||||
/* No match so far - try with a qualifier stripped (strip one qualifier at a time until none remain)
|
||||
* The order of stripping in SwigType_strip_single_qualifier is used to provide some sort of consistency
|
||||
* with the default (SWIGTYPE) typemap matching rules for the first qualifier to be stripped. */
|
||||
{
|
||||
String *octype;
|
||||
if (unstripped) {
|
||||
Delete(ctype);
|
||||
ctype = unstripped;
|
||||
unstripped = 0;
|
||||
SwigType *oldctype = ctype;
|
||||
ctype = SwigType_strip_single_qualifier(oldctype);
|
||||
if (!Equal(ctype, oldctype)) {
|
||||
Delete(oldctype);
|
||||
continue;
|
||||
}
|
||||
octype = ctype;
|
||||
ctype = SwigType_typedef_resolve(ctype);
|
||||
if (octype != type)
|
||||
Delete(octype);
|
||||
Delete(oldctype);
|
||||
}
|
||||
|
||||
/* Once all qualifiers are stripped try resolve a typedef */
|
||||
{
|
||||
SwigType *oldctype = ctype;
|
||||
ctype = SwigType_typedef_resolve(ctype_unstripped);
|
||||
Delete(oldctype);
|
||||
ctype_unstripped = Copy(ctype);
|
||||
}
|
||||
}
|
||||
|
||||
/* Hmmm. Well, no match seems to be found at all. See if there is some kind of default (SWIGTYPE) mapping */
|
||||
|
||||
primitive = SwigType_default(type);
|
||||
primitive = SwigType_default_create(type);
|
||||
while (primitive) {
|
||||
tm = get_typemap(ts, primitive);
|
||||
result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup);
|
||||
if (result)
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
|
||||
{
|
||||
SwigType *nprim = SwigType_default(primitive);
|
||||
SwigType *nprim = SwigType_default_deduce(primitive);
|
||||
Delete(primitive);
|
||||
primitive = nprim;
|
||||
}
|
||||
|
|
@ -802,12 +799,10 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
|||
|
||||
ret_result:
|
||||
Delete(primitive);
|
||||
if ((unstripped) && (unstripped != type))
|
||||
Delete(unstripped);
|
||||
if (matchtype)
|
||||
*matchtype = Copy(ctype);
|
||||
if (type != ctype)
|
||||
Delete(ctype);
|
||||
Delete(ctype);
|
||||
Delete(ctype_unstripped);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -1945,10 +1940,16 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
|||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "Swig_typemap_attach_parms: embedded\n");
|
||||
#endif
|
||||
if (!already_substituting) {
|
||||
already_substituting = 1;
|
||||
if (already_substituting < 10) {
|
||||
already_substituting++;
|
||||
if ((in_typemap_search_multi == 0) && typemap_search_debug) {
|
||||
String *dtypemap = NewString(dollar_typemap);
|
||||
Replaceall(dtypemap, "$TYPEMAP", "$typemap");
|
||||
Printf(stdout, " Containing: %s\n", dtypemap);
|
||||
Delete(dtypemap);
|
||||
}
|
||||
Swig_typemap_attach_parms(tmap_method, to_match_parms, f);
|
||||
already_substituting = 0;
|
||||
already_substituting--;
|
||||
|
||||
/* Look for the typemap code */
|
||||
attr = NewStringf("tmap:%s", tmap_method);
|
||||
|
|
@ -1979,10 +1980,11 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
|||
}
|
||||
Delete(attr);
|
||||
} else {
|
||||
/* simple recursive call check, but prevents using an embedded typemap that contains another embedded typemap */
|
||||
/* Simple recursive call check to prevent infinite recursion - this strategy only allows a limited
|
||||
* number of calls by a embedded typemaps to other embedded typemaps though */
|
||||
String *dtypemap = NewString(dollar_typemap);
|
||||
Replaceall(dtypemap, "$TYPEMAP", "$typemap");
|
||||
Swig_error(Getfile(s), Getline(s), "Recursive $typemap calls not supported - %s\n", dtypemap);
|
||||
Swig_error(Getfile(s), Getline(s), "Likely recursive $typemap calls containing %s. Use -debug-tmsearch to debug.\n", dtypemap);
|
||||
Delete(dtypemap);
|
||||
}
|
||||
syntax_error = 0;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ char cvsroot_typeobj_c[] = "$Id$";
|
|||
* 'q(str).' = Qualifier (such as const or volatile) (const, volatile)
|
||||
* 'm(qual).' = Pointer to member (qual::*)
|
||||
*
|
||||
* The complete type representation for varargs is:
|
||||
* 'v(...)'
|
||||
*
|
||||
* The encoding follows the order that you might describe a type in words.
|
||||
* For example "p.a(200).int" is "A pointer to array of int's" and
|
||||
* "p.q(const).char" is "a pointer to a const char".
|
||||
|
|
@ -181,6 +184,9 @@ SwigType *SwigType_del_element(SwigType *t) {
|
|||
* SwigType_pop()
|
||||
*
|
||||
* Pop one type element off the type.
|
||||
* Example: t in: q(const).p.Integer
|
||||
* t out: p.Integer
|
||||
* result: q(const).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_pop(SwigType *t) {
|
||||
|
|
@ -1158,3 +1164,62 @@ SwigType *SwigType_strip_qualifiers(SwigType *t) {
|
|||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_strip_single_qualifier()
|
||||
*
|
||||
* If the type contains a qualifier, strip one qualifier and return a new type.
|
||||
* The left most qualifier is stripped first (when viewed as C source code) but
|
||||
* this is the equivalent to the right most qualifier using SwigType notation.
|
||||
* Example:
|
||||
* r.q(const).p.q(const).int => r.q(const).p.int
|
||||
* r.q(const).p.int => r.p.int
|
||||
* r.p.int => r.p.int
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_strip_single_qualifier(SwigType *t) {
|
||||
static Hash *memoize_stripped = 0;
|
||||
SwigType *r = 0;
|
||||
List *l;
|
||||
int numitems;
|
||||
|
||||
if (!memoize_stripped)
|
||||
memoize_stripped = NewHash();
|
||||
r = Getattr(memoize_stripped, t);
|
||||
if (r)
|
||||
return Copy(r);
|
||||
|
||||
l = SwigType_split(t);
|
||||
|
||||
numitems = Len(l);
|
||||
if (numitems >= 2) {
|
||||
int item;
|
||||
/* iterate backwards from last but one item */
|
||||
for (item = numitems - 2; item >= 0; --item) {
|
||||
String *subtype = Getitem(l, item);
|
||||
if (SwigType_isqualifier(subtype)) {
|
||||
Iterator it;
|
||||
Delitem(l, item);
|
||||
r = NewStringEmpty();
|
||||
for (it = First(l); it.item; it = Next(it)) {
|
||||
Append(r, it.item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!r)
|
||||
r = Copy(t);
|
||||
|
||||
Delete(l);
|
||||
{
|
||||
String *key, *value;
|
||||
key = Copy(t);
|
||||
value = Copy(r);
|
||||
Setattr(memoize_stripped, key, value);
|
||||
Delete(key);
|
||||
Delete(value);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ char cvsroot_typesys_c[] = "$Id$";
|
|||
*
|
||||
* class Bar : public Foo {
|
||||
* void blah(Integer x);
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* The argument type of Bar::blah will be set to Foo::Integer.
|
||||
*
|
||||
|
|
@ -1782,7 +1782,7 @@ void SwigType_inherit_equiv(File *out) {
|
|||
continue;
|
||||
}
|
||||
|
||||
/* This type has subclasses. We now need to walk through these subtypes and generate pointer converion functions */
|
||||
/* This type has subclasses. We now need to walk through these subtypes and generate pointer conversion functions */
|
||||
|
||||
rh = Getattr(r_resolved, rk.key);
|
||||
rlist = NewList();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue