Remove unnecessary duplicate typemap lookup

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11833 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-01-29 06:55:38 +00:00
commit a4d28ba148
3 changed files with 24 additions and 2 deletions

View file

@ -158,6 +158,7 @@ extern "C" {
extern String *SwigType_namestr(const SwigType *t);
extern String *SwigType_templateprefix(const SwigType *t);
extern String *SwigType_templatesuffix(const SwigType *t);
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);

View file

@ -705,9 +705,9 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
/* look for the type reduced to just the template prefix */
Delete(template_prefix);
template_prefix = SwigType_templateprefix(ctype);
tm = get_typemap(ts, template_prefix);
template_prefix = SwigType_istemplate_templateprefix(ctype);
if (template_prefix) {
tm = get_typemap(ts, template_prefix);
if (debug_display && cqualifiedname)
Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, cqualifiedname));
if (tm && cqualifiedname) {

View file

@ -852,10 +852,12 @@ SwigType *SwigType_add_template(SwigType *t, ParmList *parms) {
* SwigType_templateprefix()
*
* Returns the prefix before the first template definition.
* Returns the type unmodified if not a template.
* For example:
*
* Foo<(p.int)>::bar => Foo
* r.q(const).Foo<(p.int)>::bar => r.q(const).Foo
* Foo => Foo
* ----------------------------------------------------------------------------- */
String *SwigType_templateprefix(const SwigType *t) {
@ -896,6 +898,25 @@ String *SwigType_templatesuffix(const SwigType *t) {
return NewStringEmpty();
}
/* -----------------------------------------------------------------------------
* SwigType_istemplate_templateprefix()
*
* Combines SwigType_istemplate and SwigType_templateprefix efficiently into one function.
* Returns the prefix before the first template definition.
* Returns NULL if not a template.
* For example:
*
* Foo<(p.int)>::bar => Foo
* r.q(const).Foo<(p.int)>::bar => r.q(const).Foo
* Foo => NULL
* ----------------------------------------------------------------------------- */
String *SwigType_istemplate_templateprefix(const SwigType *t) {
const char *s = Char(t);
const char *c = strstr(s, "<(");
return c ? NewStringWithSize(s, c - s) : 0;
}
/* -----------------------------------------------------------------------------
* SwigType_templateargs()
*