Merge pull request #522 from vadz/drop-tm-scope
Remove unused support for typemap scopes
This commit is contained in:
commit
d20de7bcfc
2 changed files with 157 additions and 217 deletions
|
|
@ -409,8 +409,6 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
||||||
|
|
||||||
extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f);
|
extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f);
|
||||||
extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
|
extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
|
||||||
extern void Swig_typemap_new_scope(void);
|
|
||||||
extern Hash *Swig_typemap_pop_scope(void);
|
|
||||||
|
|
||||||
extern void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f);
|
extern void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,9 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
||||||
*
|
*
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define MAX_SCOPE 32
|
static Hash *typemaps;
|
||||||
|
|
||||||
|
static Hash *get_typemap(const SwigType *type) {
|
||||||
static Hash *typemaps[MAX_SCOPE];
|
|
||||||
static int tm_scope = 0;
|
|
||||||
|
|
||||||
static Hash *get_typemap(int tm_scope, const SwigType *type) {
|
|
||||||
Hash *tm = 0;
|
Hash *tm = 0;
|
||||||
SwigType *dtype = 0;
|
SwigType *dtype = 0;
|
||||||
SwigType *hashtype;
|
SwigType *hashtype;
|
||||||
|
|
@ -79,7 +75,7 @@ static Hash *get_typemap(int tm_scope, const SwigType *type) {
|
||||||
|
|
||||||
/* remove unary scope operator (::) prefix indicating global scope for looking up in the hashmap */
|
/* remove unary scope operator (::) prefix indicating global scope for looking up in the hashmap */
|
||||||
hashtype = SwigType_remove_global_scope_prefix(type);
|
hashtype = SwigType_remove_global_scope_prefix(type);
|
||||||
tm = Getattr(typemaps[tm_scope], hashtype);
|
tm = Getattr(typemaps, hashtype);
|
||||||
|
|
||||||
Delete(dtype);
|
Delete(dtype);
|
||||||
Delete(hashtype);
|
Delete(hashtype);
|
||||||
|
|
@ -87,7 +83,7 @@ static Hash *get_typemap(int tm_scope, const SwigType *type) {
|
||||||
return tm;
|
return tm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) {
|
static void set_typemap(const SwigType *type, Hash **tmhash) {
|
||||||
SwigType *hashtype = 0;
|
SwigType *hashtype = 0;
|
||||||
Hash *new_tm = 0;
|
Hash *new_tm = 0;
|
||||||
assert(*tmhash == 0);
|
assert(*tmhash == 0);
|
||||||
|
|
@ -96,7 +92,7 @@ static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) {
|
||||||
String *ty = Swig_symbol_template_deftype(rty, 0);
|
String *ty = Swig_symbol_template_deftype(rty, 0);
|
||||||
String *tyq = Swig_symbol_type_qualify(ty, 0);
|
String *tyq = Swig_symbol_type_qualify(ty, 0);
|
||||||
hashtype = SwigType_remove_global_scope_prefix(tyq);
|
hashtype = SwigType_remove_global_scope_prefix(tyq);
|
||||||
*tmhash = Getattr(typemaps[tm_scope], hashtype);
|
*tmhash = Getattr(typemaps, hashtype);
|
||||||
Delete(rty);
|
Delete(rty);
|
||||||
Delete(tyq);
|
Delete(tyq);
|
||||||
Delete(ty);
|
Delete(ty);
|
||||||
|
|
@ -111,7 +107,7 @@ static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* note that the unary scope operator (::) prefix indicating global scope has been removed from the type */
|
/* note that the unary scope operator (::) prefix indicating global scope has been removed from the type */
|
||||||
Setattr(typemaps[tm_scope], hashtype, *tmhash);
|
Setattr(typemaps, hashtype, *tmhash);
|
||||||
|
|
||||||
Delete(hashtype);
|
Delete(hashtype);
|
||||||
Delete(new_tm);
|
Delete(new_tm);
|
||||||
|
|
@ -125,12 +121,7 @@ static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Swig_typemap_init() {
|
void Swig_typemap_init() {
|
||||||
int i;
|
typemaps = NewHash();
|
||||||
for (i = 0; i < MAX_SCOPE; i++) {
|
|
||||||
typemaps[i] = 0;
|
|
||||||
}
|
|
||||||
typemaps[0] = NewHash();
|
|
||||||
tm_scope = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static String *typemap_method_name(const_String_or_char_ptr tmap_method) {
|
static String *typemap_method_name(const_String_or_char_ptr tmap_method) {
|
||||||
|
|
@ -160,32 +151,6 @@ static String *typemap_method_name(const_String_or_char_ptr tmap_method) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Swig_typemap_new_scope()
|
|
||||||
*
|
|
||||||
* Create a new typemap scope
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void Swig_typemap_new_scope() {
|
|
||||||
tm_scope++;
|
|
||||||
typemaps[tm_scope] = NewHash();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
|
||||||
* Swig_typemap_pop_scope()
|
|
||||||
*
|
|
||||||
* Pop the last typemap scope off
|
|
||||||
* ----------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
Hash *Swig_typemap_pop_scope() {
|
|
||||||
if (tm_scope > 0) {
|
|
||||||
return typemaps[tm_scope--];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* typemap_register()
|
* typemap_register()
|
||||||
*
|
*
|
||||||
|
|
@ -216,9 +181,9 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par
|
||||||
pname = Getattr(parms, "name");
|
pname = Getattr(parms, "name");
|
||||||
|
|
||||||
/* See if this type has been seen before */
|
/* See if this type has been seen before */
|
||||||
tm = get_typemap(tm_scope, type);
|
tm = get_typemap(type);
|
||||||
if (!tm) {
|
if (!tm) {
|
||||||
set_typemap(tm_scope, type, &tm);
|
set_typemap(type, &tm);
|
||||||
}
|
}
|
||||||
if (pname) {
|
if (pname) {
|
||||||
/* See if parameter has been seen before */
|
/* See if parameter has been seen before */
|
||||||
|
|
@ -311,15 +276,12 @@ void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* typemap_get()
|
* typemap_get()
|
||||||
*
|
*
|
||||||
* Retrieve typemap information from current scope.
|
* Retrieve typemap information.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static Hash *typemap_get(SwigType *type, const_String_or_char_ptr name, int scope) {
|
static Hash *typemap_get(SwigType *type, const_String_or_char_ptr name) {
|
||||||
Hash *tm, *tm1;
|
Hash *tm, *tm1;
|
||||||
/* See if this type has been seen before */
|
tm = get_typemap(type);
|
||||||
if ((scope < 0) || (scope > tm_scope))
|
|
||||||
return 0;
|
|
||||||
tm = get_typemap(scope, type);
|
|
||||||
if (!tm) {
|
if (!tm) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -342,51 +304,48 @@ int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcparms,
|
||||||
Parm *p;
|
Parm *p;
|
||||||
String *pname;
|
String *pname;
|
||||||
SwigType *ptype;
|
SwigType *ptype;
|
||||||
int ts = tm_scope;
|
|
||||||
String *tm_methods, *multi_tmap_method;
|
String *tm_methods, *multi_tmap_method;
|
||||||
if (ParmList_len(parms) != ParmList_len(srcparms))
|
if (ParmList_len(parms) != ParmList_len(srcparms))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
tm_method = typemap_method_name(tmap_method);
|
tm_method = typemap_method_name(tmap_method);
|
||||||
while (ts >= 0) {
|
p = srcparms;
|
||||||
p = srcparms;
|
tm_methods = NewString(tm_method);
|
||||||
tm_methods = NewString(tm_method);
|
while (p) {
|
||||||
while (p) {
|
ptype = Getattr(p, "type");
|
||||||
ptype = Getattr(p, "type");
|
pname = Getattr(p, "name");
|
||||||
pname = Getattr(p, "name");
|
|
||||||
|
|
||||||
/* Lookup the type */
|
/* Lookup the type */
|
||||||
tm = typemap_get(ptype, pname, ts);
|
tm = typemap_get(ptype, pname);
|
||||||
if (!tm)
|
if (!tm)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tm = Getattr(tm, tm_methods);
|
tm = Getattr(tm, tm_methods);
|
||||||
if (!tm)
|
if (!tm)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Got a match. Look for next typemap */
|
/* Got a match. Look for next typemap */
|
||||||
multi_tmap_method = NewStringf("%s-%s+%s:", tm_methods, ptype, pname);
|
multi_tmap_method = NewStringf("%s-%s+%s:", tm_methods, ptype, pname);
|
||||||
Delete(tm_methods);
|
|
||||||
tm_methods = multi_tmap_method;
|
|
||||||
p = nextSibling(p);
|
|
||||||
}
|
|
||||||
Delete(tm_methods);
|
Delete(tm_methods);
|
||||||
|
tm_methods = multi_tmap_method;
|
||||||
if (!p && tm) {
|
p = nextSibling(p);
|
||||||
/* Got some kind of match */
|
|
||||||
String *parms_str = ParmList_str_multibrackets(parms);
|
|
||||||
String *srcparms_str = ParmList_str_multibrackets(srcparms);
|
|
||||||
String *source_directive = NewStringf("typemap(%s) %s = %s", tmap_method, parms_str, srcparms_str);
|
|
||||||
|
|
||||||
typemap_register(tmap_method, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs"), source_directive);
|
|
||||||
|
|
||||||
Delete(source_directive);
|
|
||||||
Delete(srcparms_str);
|
|
||||||
Delete(parms_str);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ts--;
|
|
||||||
}
|
}
|
||||||
|
Delete(tm_methods);
|
||||||
|
|
||||||
|
if (!p && tm) {
|
||||||
|
/* Got some kind of match */
|
||||||
|
String *parms_str = ParmList_str_multibrackets(parms);
|
||||||
|
String *srcparms_str = ParmList_str_multibrackets(srcparms);
|
||||||
|
String *source_directive = NewStringf("typemap(%s) %s = %s", tmap_method, parms_str, srcparms_str);
|
||||||
|
|
||||||
|
typemap_register(tmap_method, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs"), source_directive);
|
||||||
|
|
||||||
|
Delete(source_directive);
|
||||||
|
Delete(srcparms_str);
|
||||||
|
Delete(parms_str);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Not found */
|
/* Not found */
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
@ -411,7 +370,7 @@ void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *parms) {
|
||||||
while (p) {
|
while (p) {
|
||||||
type = Getattr(p, "type");
|
type = Getattr(p, "type");
|
||||||
name = Getattr(p, "name");
|
name = Getattr(p, "name");
|
||||||
tm = typemap_get(type, name, tm_scope);
|
tm = typemap_get(type, name);
|
||||||
if (!tm)
|
if (!tm)
|
||||||
return;
|
return;
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
|
|
@ -452,7 +411,6 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) {
|
||||||
String *ssig, *dsig;
|
String *ssig, *dsig;
|
||||||
Parm *p, *np, *lastp, *dp, *lastdp = 0;
|
Parm *p, *np, *lastp, *dp, *lastdp = 0;
|
||||||
int narg = 0;
|
int narg = 0;
|
||||||
int ts = tm_scope;
|
|
||||||
SwigType *type = 0, *name;
|
SwigType *type = 0, *name;
|
||||||
Hash *tm, *sm;
|
Hash *tm, *sm;
|
||||||
int match = 0;
|
int match = 0;
|
||||||
|
|
@ -480,9 +438,9 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) {
|
||||||
|
|
||||||
/* make sure a typemap node exists for the last destination node */
|
/* make sure a typemap node exists for the last destination node */
|
||||||
type = Getattr(lastdp, "type");
|
type = Getattr(lastdp, "type");
|
||||||
tm = get_typemap(tm_scope, type);
|
tm = get_typemap(type);
|
||||||
if (!tm) {
|
if (!tm) {
|
||||||
set_typemap(tm_scope, type, &tm);
|
set_typemap(type, &tm);
|
||||||
}
|
}
|
||||||
name = Getattr(lastdp, "name");
|
name = Getattr(lastdp, "name");
|
||||||
if (name) {
|
if (name) {
|
||||||
|
|
@ -501,69 +459,65 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) {
|
||||||
type = Getattr(lastp, "type");
|
type = Getattr(lastp, "type");
|
||||||
name = Getattr(lastp, "name");
|
name = Getattr(lastp, "name");
|
||||||
|
|
||||||
while (ts >= 0) {
|
/* See if there is a matching typemap in this scope */
|
||||||
|
sm = typemap_get(type, name);
|
||||||
|
|
||||||
/* See if there is a matching typemap in this scope */
|
/* if there is not matching, look for a typemap in the
|
||||||
sm = typemap_get(type, name, ts);
|
original typedef, if any, like in:
|
||||||
|
|
||||||
/* if there is not matching, look for a typemap in the
|
typedef unsigned long size_t;
|
||||||
original typedef, if any, like in:
|
...
|
||||||
|
%apply(size_t) {my_size}; ==> %apply(unsigned long) {my_size};
|
||||||
typedef unsigned long size_t;
|
*/
|
||||||
...
|
if (!sm) {
|
||||||
%apply(size_t) {my_size}; ==> %apply(unsigned long) {my_size};
|
SwigType *ntype = SwigType_typedef_resolve(type);
|
||||||
*/
|
if (ntype && (Cmp(ntype, type) != 0)) {
|
||||||
if (!sm) {
|
sm = typemap_get(ntype, name);
|
||||||
SwigType *ntype = SwigType_typedef_resolve(type);
|
|
||||||
if (ntype && (Cmp(ntype, type) != 0)) {
|
|
||||||
sm = typemap_get(ntype, name, ts);
|
|
||||||
}
|
|
||||||
Delete(ntype);
|
|
||||||
}
|
}
|
||||||
|
Delete(ntype);
|
||||||
|
}
|
||||||
|
|
||||||
if (sm) {
|
if (sm) {
|
||||||
/* Got a typemap. Need to only merge attributes for methods that match our signature */
|
/* Got a typemap. Need to only merge attributes for methods that match our signature */
|
||||||
Iterator ki;
|
Iterator ki;
|
||||||
match = 1;
|
match = 1;
|
||||||
for (ki = First(sm); ki.key; ki = Next(ki)) {
|
for (ki = First(sm); ki.key; ki = Next(ki)) {
|
||||||
/* Check for a signature match with the source signature */
|
/* Check for a signature match with the source signature */
|
||||||
if ((count_args(ki.key) == narg) && (Strstr(ki.key, ssig))) {
|
if ((count_args(ki.key) == narg) && (Strstr(ki.key, ssig))) {
|
||||||
String *oldm;
|
String *oldm;
|
||||||
/* A typemap we have to copy */
|
/* A typemap we have to copy */
|
||||||
String *nkey = Copy(ki.key);
|
String *nkey = Copy(ki.key);
|
||||||
Replace(nkey, ssig, dsig, DOH_REPLACE_ANY);
|
Replace(nkey, ssig, dsig, DOH_REPLACE_ANY);
|
||||||
|
|
||||||
/* Make sure the typemap doesn't already exist in the target map */
|
/* Make sure the typemap doesn't already exist in the target map */
|
||||||
|
|
||||||
oldm = Getattr(tm, nkey);
|
oldm = Getattr(tm, nkey);
|
||||||
if (!oldm || (!Getattr(tm, "code"))) {
|
if (!oldm || (!Getattr(tm, "code"))) {
|
||||||
String *code;
|
String *code;
|
||||||
ParmList *locals;
|
ParmList *locals;
|
||||||
ParmList *kwargs;
|
ParmList *kwargs;
|
||||||
Hash *sm1 = ki.item;
|
Hash *sm1 = ki.item;
|
||||||
|
|
||||||
code = Getattr(sm1, "code");
|
code = Getattr(sm1, "code");
|
||||||
locals = Getattr(sm1, "locals");
|
locals = Getattr(sm1, "locals");
|
||||||
kwargs = Getattr(sm1, "kwargs");
|
kwargs = Getattr(sm1, "kwargs");
|
||||||
if (code) {
|
if (code) {
|
||||||
String *src_str = ParmList_str_multibrackets(src);
|
String *src_str = ParmList_str_multibrackets(src);
|
||||||
String *dest_str = ParmList_str_multibrackets(dest);
|
String *dest_str = ParmList_str_multibrackets(dest);
|
||||||
String *source_directive = NewStringf("apply %s { %s }", src_str, dest_str);
|
String *source_directive = NewStringf("apply %s { %s }", src_str, dest_str);
|
||||||
|
|
||||||
Replace(nkey, dsig, "", DOH_REPLACE_ANY);
|
Replace(nkey, dsig, "", DOH_REPLACE_ANY);
|
||||||
Replace(nkey, "tmap:", "", DOH_REPLACE_ANY);
|
Replace(nkey, "tmap:", "", DOH_REPLACE_ANY);
|
||||||
typemap_register(nkey, dest, code, locals, kwargs, source_directive);
|
typemap_register(nkey, dest, code, locals, kwargs, source_directive);
|
||||||
|
|
||||||
Delete(source_directive);
|
Delete(source_directive);
|
||||||
Delete(dest_str);
|
Delete(dest_str);
|
||||||
Delete(src_str);
|
Delete(src_str);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Delete(nkey);
|
|
||||||
}
|
}
|
||||||
|
Delete(nkey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ts--;
|
|
||||||
}
|
}
|
||||||
Delete(ssig);
|
Delete(ssig);
|
||||||
Delete(dsig);
|
Delete(dsig);
|
||||||
|
|
@ -597,7 +551,7 @@ void Swig_typemap_clear_apply(Parm *parms) {
|
||||||
}
|
}
|
||||||
p = np;
|
p = np;
|
||||||
}
|
}
|
||||||
tm = get_typemap(tm_scope, Getattr(lastp, "type"));
|
tm = get_typemap(Getattr(lastp, "type"));
|
||||||
if (!tm) {
|
if (!tm) {
|
||||||
Delete(tsig);
|
Delete(tsig);
|
||||||
return;
|
return;
|
||||||
|
|
@ -711,7 +665,6 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
||||||
SwigType *primitive = 0;
|
SwigType *primitive = 0;
|
||||||
SwigType *ctype = 0;
|
SwigType *ctype = 0;
|
||||||
SwigType *ctype_unstripped = 0;
|
SwigType *ctype_unstripped = 0;
|
||||||
int ts;
|
|
||||||
int isarray;
|
int isarray;
|
||||||
const String *cname = 0;
|
const String *cname = 0;
|
||||||
const String *cqualifiedname = 0;
|
const String *cqualifiedname = 0;
|
||||||
|
|
@ -722,90 +675,86 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
||||||
cname = name;
|
cname = name;
|
||||||
if ((qualifiedname) && Len(qualifiedname))
|
if ((qualifiedname) && Len(qualifiedname))
|
||||||
cqualifiedname = qualifiedname;
|
cqualifiedname = qualifiedname;
|
||||||
ts = tm_scope;
|
|
||||||
|
|
||||||
if (debug_display) {
|
if (debug_display) {
|
||||||
String *typestr = SwigType_str(type, cqualifiedname ? cqualifiedname : cname);
|
String *typestr = SwigType_str(type, cqualifiedname ? cqualifiedname : cname);
|
||||||
Swig_diagnostic(Getfile(node), Getline(node), "Searching for a suitable '%s' typemap for: %s\n", tmap_method, typestr);
|
Swig_diagnostic(Getfile(node), Getline(node), "Searching for a suitable '%s' typemap for: %s\n", tmap_method, typestr);
|
||||||
Delete(typestr);
|
Delete(typestr);
|
||||||
}
|
}
|
||||||
while (ts >= 0) {
|
ctype = Copy(type);
|
||||||
ctype = Copy(type);
|
ctype_unstripped = Copy(ctype);
|
||||||
ctype_unstripped = Copy(ctype);
|
while (ctype) {
|
||||||
while (ctype) {
|
/* Try to get an exact type-match */
|
||||||
/* Try to get an exact type-match */
|
tm = get_typemap(ctype);
|
||||||
tm = get_typemap(ts, ctype);
|
result = typemap_search_helper(debug_display, tm, tm_method, ctype, cqualifiedname, cname, &backup);
|
||||||
result = typemap_search_helper(debug_display, tm, tm_method, ctype, cqualifiedname, cname, &backup);
|
if (result && Getattr(result, "code"))
|
||||||
if (result && Getattr(result, "code"))
|
goto ret_result;
|
||||||
goto ret_result;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Look for the type reduced to just the template prefix - for templated types without the template parameter list being specified */
|
/* Look for the type reduced to just the template prefix - for templated types without the template parameter list being specified */
|
||||||
SwigType *template_prefix = SwigType_istemplate_only_templateprefix(ctype);
|
SwigType *template_prefix = SwigType_istemplate_only_templateprefix(ctype);
|
||||||
if (template_prefix) {
|
if (template_prefix) {
|
||||||
tm = get_typemap(ts, template_prefix);
|
tm = get_typemap(template_prefix);
|
||||||
result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup);
|
result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup);
|
||||||
Delete(template_prefix);
|
Delete(template_prefix);
|
||||||
if (result && Getattr(result, "code"))
|
|
||||||
goto ret_result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* look for [ANY] arrays */
|
|
||||||
isarray = SwigType_isarray(ctype);
|
|
||||||
if (isarray) {
|
|
||||||
/* If working with arrays, strip away all of the dimensions and replace with "ANY".
|
|
||||||
See if that generates a match */
|
|
||||||
SwigType *noarrays = strip_arrays(ctype);
|
|
||||||
tm = get_typemap(ts, noarrays);
|
|
||||||
result = typemap_search_helper(debug_display, tm, tm_method, noarrays, cqualifiedname, cname, &backup);
|
|
||||||
Delete(noarrays);
|
|
||||||
if (result && Getattr(result, "code"))
|
if (result && Getattr(result, "code"))
|
||||||
goto ret_result;
|
goto ret_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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. */
|
|
||||||
{
|
|
||||||
SwigType *oldctype = ctype;
|
|
||||||
ctype = SwigType_strip_single_qualifier(oldctype);
|
|
||||||
if (!Equal(ctype, oldctype)) {
|
|
||||||
Delete(oldctype);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
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 */
|
/* look for [ANY] arrays */
|
||||||
|
isarray = SwigType_isarray(ctype);
|
||||||
primitive = SwigType_default_create(type);
|
if (isarray) {
|
||||||
while (primitive) {
|
/* If working with arrays, strip away all of the dimensions and replace with "ANY".
|
||||||
tm = get_typemap(ts, primitive);
|
See if that generates a match */
|
||||||
result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup);
|
SwigType *noarrays = strip_arrays(ctype);
|
||||||
|
tm = get_typemap(noarrays);
|
||||||
|
result = typemap_search_helper(debug_display, tm, tm_method, noarrays, cqualifiedname, cname, &backup);
|
||||||
|
Delete(noarrays);
|
||||||
if (result && Getattr(result, "code"))
|
if (result && Getattr(result, "code"))
|
||||||
goto ret_result;
|
goto ret_result;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
/* No match so far - try with a qualifier stripped (strip one qualifier at a time until none remain)
|
||||||
SwigType *nprim = SwigType_default_deduce(primitive);
|
* The order of stripping in SwigType_strip_single_qualifier is used to provide some sort of consistency
|
||||||
Delete(primitive);
|
* with the default (SWIGTYPE) typemap matching rules for the first qualifier to be stripped. */
|
||||||
primitive = nprim;
|
{
|
||||||
|
SwigType *oldctype = ctype;
|
||||||
|
ctype = SwigType_strip_single_qualifier(oldctype);
|
||||||
|
if (!Equal(ctype, oldctype)) {
|
||||||
|
Delete(oldctype);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
Delete(oldctype);
|
||||||
}
|
}
|
||||||
if (ctype != type) {
|
|
||||||
Delete(ctype);
|
/* Once all qualifiers are stripped try resolve a typedef */
|
||||||
ctype = 0;
|
{
|
||||||
|
SwigType *oldctype = ctype;
|
||||||
|
ctype = SwigType_typedef_resolve(ctype_unstripped);
|
||||||
|
Delete(oldctype);
|
||||||
|
ctype_unstripped = Copy(ctype);
|
||||||
}
|
}
|
||||||
ts--; /* Hmmm. Nothing found in this scope. Guess we'll go try another scope */
|
}
|
||||||
|
|
||||||
|
/* Hmmm. Well, no match seems to be found at all. See if there is some kind of default (SWIGTYPE) mapping */
|
||||||
|
|
||||||
|
primitive = SwigType_default_create(type);
|
||||||
|
while (primitive) {
|
||||||
|
tm = get_typemap(primitive);
|
||||||
|
result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup);
|
||||||
|
if (result && Getattr(result, "code"))
|
||||||
|
goto ret_result;
|
||||||
|
|
||||||
|
{
|
||||||
|
SwigType *nprim = SwigType_default_deduce(primitive);
|
||||||
|
Delete(primitive);
|
||||||
|
primitive = nprim;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ctype != type) {
|
||||||
|
Delete(ctype);
|
||||||
|
ctype = 0;
|
||||||
}
|
}
|
||||||
result = backup;
|
result = backup;
|
||||||
|
|
||||||
|
|
@ -2110,16 +2059,9 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Swig_typemap_debug() {
|
void Swig_typemap_debug() {
|
||||||
int ts;
|
|
||||||
int nesting_level = 2;
|
int nesting_level = 2;
|
||||||
Printf(stdout, "---[ typemaps ]--------------------------------------------------------------\n");
|
Printf(stdout, "---[ typemaps ]--------------------------------------------------------------\n");
|
||||||
|
Swig_print(typemaps, nesting_level);
|
||||||
ts = tm_scope;
|
|
||||||
while (ts >= 0) {
|
|
||||||
Printf(stdout, "::: scope %d\n\n", ts);
|
|
||||||
Swig_print(typemaps[ts], nesting_level);
|
|
||||||
ts--;
|
|
||||||
}
|
|
||||||
Printf(stdout, "-----------------------------------------------------------------------------\n");
|
Printf(stdout, "-----------------------------------------------------------------------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue