Factor out the common code within typemap_search() into typemap_search_helper()
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11838 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
160ce6d4a8
commit
590567d57f
1 changed files with 72 additions and 139 deletions
|
|
@ -630,6 +630,56 @@ static void debug_search_result_display(Node *tm) {
|
||||||
Printf(stdout, " None found\n");
|
Printf(stdout, " None found\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* typemap_search_helper()
|
||||||
|
*
|
||||||
|
* Helper function for typemap_search to see if there is a type match in the typemap
|
||||||
|
* tm. A match is sought in this order:
|
||||||
|
* %typemap(tm_method) ctype cqualifiedname
|
||||||
|
* %typemap(tm_method) ctype cname
|
||||||
|
* %typemap(tm_method) ctype
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static Hash *typemap_search_helper(int debug_display, Hash *tm, const String *tm_method, SwigType *ctype, const String *cqualifiedname, const String *cname, Hash **backup) {
|
||||||
|
Hash *result = 0;
|
||||||
|
Hash *tm1;
|
||||||
|
if (debug_display && cqualifiedname)
|
||||||
|
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cqualifiedname));
|
||||||
|
if (tm && cqualifiedname) {
|
||||||
|
tm1 = Getattr(tm, cqualifiedname);
|
||||||
|
if (tm1) {
|
||||||
|
result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */
|
||||||
|
if (result && Getattr(result, "code"))
|
||||||
|
goto ret_result;
|
||||||
|
if (result)
|
||||||
|
*backup = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (debug_display && cname)
|
||||||
|
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cname));
|
||||||
|
if (tm && cname) {
|
||||||
|
tm1 = Getattr(tm, cname);
|
||||||
|
if (tm1) {
|
||||||
|
result = Getattr(tm1, tm_method); /* See if there is a type - name match */
|
||||||
|
if (result && Getattr(result, "code"))
|
||||||
|
goto ret_result;
|
||||||
|
if (result)
|
||||||
|
*backup = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 */
|
||||||
|
if (result && Getattr(result, "code"))
|
||||||
|
goto ret_result;
|
||||||
|
if (result)
|
||||||
|
*backup = result;
|
||||||
|
}
|
||||||
|
ret_result:
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* typemap_search()
|
* typemap_search()
|
||||||
*
|
*
|
||||||
|
|
@ -639,12 +689,11 @@ static void debug_search_result_display(Node *tm) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, const_String_or_char_ptr qualifiedname, SwigType **matchtype, Node *node) {
|
static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, const_String_or_char_ptr qualifiedname, SwigType **matchtype, Node *node) {
|
||||||
Hash *result = 0, *tm, *tm1, *tma;
|
Hash *result = 0;
|
||||||
|
Hash *tm;
|
||||||
Hash *backup = 0;
|
Hash *backup = 0;
|
||||||
SwigType *noarrays = 0;
|
|
||||||
SwigType *primitive = 0;
|
SwigType *primitive = 0;
|
||||||
SwigType *ctype = 0;
|
SwigType *ctype = 0;
|
||||||
SwigType *template_prefix = 0;
|
|
||||||
int ts;
|
int ts;
|
||||||
int isarray;
|
int isarray;
|
||||||
const String *cname = 0;
|
const String *cname = 0;
|
||||||
|
|
@ -669,77 +718,19 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
||||||
while (ctype) {
|
while (ctype) {
|
||||||
/* Try to get an exact type-match */
|
/* Try to get an exact type-match */
|
||||||
tm = get_typemap(ts, ctype);
|
tm = get_typemap(ts, ctype);
|
||||||
if (debug_display && cqualifiedname)
|
result = typemap_search_helper(debug_display, tm, tm_method, ctype, cqualifiedname, cname, &backup);
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cqualifiedname));
|
if (result)
|
||||||
if (tm && cqualifiedname) {
|
goto ret_result;
|
||||||
tm1 = Getattr(tm, cqualifiedname);
|
|
||||||
if (tm1) {
|
|
||||||
result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */
|
|
||||||
if (result && Getattr(result, "code"))
|
|
||||||
goto ret_result;
|
|
||||||
if (result)
|
|
||||||
backup = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (debug_display && cname)
|
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cname));
|
|
||||||
if (tm && cname) {
|
|
||||||
tm1 = Getattr(tm, cname);
|
|
||||||
if (tm1) {
|
|
||||||
result = Getattr(tm1, tm_method); /* See if there is a type - name match */
|
|
||||||
if (result && Getattr(result, "code"))
|
|
||||||
goto ret_result;
|
|
||||||
if (result)
|
|
||||||
backup = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 */
|
|
||||||
if (result && Getattr(result, "code"))
|
|
||||||
goto ret_result;
|
|
||||||
if (result)
|
|
||||||
backup = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* look for the type reduced to just the template prefix */
|
{
|
||||||
Delete(template_prefix);
|
/* Look for the type reduced to just the template prefix */
|
||||||
template_prefix = SwigType_istemplate_templateprefix(ctype);
|
SwigType *template_prefix = SwigType_istemplate_templateprefix(ctype);
|
||||||
if (template_prefix) {
|
if (template_prefix) {
|
||||||
tm = get_typemap(ts, template_prefix);
|
tm = get_typemap(ts, template_prefix);
|
||||||
if (debug_display && cqualifiedname)
|
result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup);
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, cqualifiedname));
|
Delete(template_prefix);
|
||||||
if (tm && cqualifiedname) {
|
|
||||||
tm1 = Getattr(tm, cqualifiedname);
|
|
||||||
if (tm1) {
|
|
||||||
result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */
|
|
||||||
if (result && Getattr(result, "code"))
|
|
||||||
goto ret_result;
|
|
||||||
if (result)
|
|
||||||
backup = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (debug_display && cname)
|
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, cname));
|
|
||||||
if (tm && cname) {
|
|
||||||
tm1 = Getattr(tm, cname);
|
|
||||||
if (tm1) {
|
|
||||||
result = Getattr(tm1, tm_method); /* See if there is a type - name match */
|
|
||||||
if (result && Getattr(result, "code"))
|
|
||||||
goto ret_result;
|
|
||||||
if (result)
|
|
||||||
backup = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (debug_display)
|
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, 0));
|
|
||||||
if (tm) {
|
|
||||||
result = Getattr(tm, tm_method); /* See if there is simply a type match */
|
|
||||||
if (result && Getattr(result, "code"))
|
|
||||||
goto ret_result;
|
|
||||||
if (result)
|
if (result)
|
||||||
backup = result;
|
goto ret_result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -748,45 +739,12 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
||||||
if (isarray) {
|
if (isarray) {
|
||||||
/* If working with arrays, strip away all of the dimensions and replace with "ANY".
|
/* If working with arrays, strip away all of the dimensions and replace with "ANY".
|
||||||
See if that generates a match */
|
See if that generates a match */
|
||||||
if (!noarrays) {
|
SwigType *noarrays = strip_arrays(ctype);
|
||||||
noarrays = strip_arrays(ctype);
|
tm = get_typemap(ts, noarrays);
|
||||||
}
|
result = typemap_search_helper(debug_display, tm, tm_method, noarrays, cqualifiedname, cname, &backup);
|
||||||
tma = get_typemap(ts, noarrays);
|
|
||||||
if (debug_display && cqualifiedname)
|
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, cqualifiedname));
|
|
||||||
if (tma && cqualifiedname) {
|
|
||||||
tm1 = Getattr(tma, cqualifiedname);
|
|
||||||
if (tm1) {
|
|
||||||
result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */
|
|
||||||
if (result && Getattr(result, "code"))
|
|
||||||
goto ret_result;
|
|
||||||
if (result)
|
|
||||||
backup = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (debug_display && cname)
|
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, cname));
|
|
||||||
if (tma && cname) {
|
|
||||||
tm1 = Getattr(tma, cname);
|
|
||||||
if (tm1) {
|
|
||||||
result = Getattr(tm1, tm_method); /* See if there is a type - name match */
|
|
||||||
if (result && Getattr(result, "code"))
|
|
||||||
goto ret_result;
|
|
||||||
if (result)
|
|
||||||
backup = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (debug_display)
|
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, 0));
|
|
||||||
if (tma) {
|
|
||||||
result = Getattr(tma, tm_method); /* See if there is a type match */
|
|
||||||
if (result && Getattr(result, "code"))
|
|
||||||
goto ret_result;
|
|
||||||
if (result)
|
|
||||||
backup = result;
|
|
||||||
}
|
|
||||||
Delete(noarrays);
|
Delete(noarrays);
|
||||||
noarrays = 0;
|
if (result)
|
||||||
|
goto ret_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No match so far. If the type is unstripped, we'll strip its
|
/* No match so far. If the type is unstripped, we'll strip its
|
||||||
|
|
@ -820,33 +778,10 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
||||||
primitive = SwigType_default(type);
|
primitive = SwigType_default(type);
|
||||||
while (primitive) {
|
while (primitive) {
|
||||||
tm = get_typemap(ts, primitive);
|
tm = get_typemap(ts, primitive);
|
||||||
if (debug_display && cqualifiedname)
|
result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup);
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, cqualifiedname));
|
if (result)
|
||||||
if (tm && cqualifiedname) {
|
goto ret_result;
|
||||||
tm1 = Getattr(tm, cqualifiedname);
|
|
||||||
if (tm1) {
|
|
||||||
result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */
|
|
||||||
if (result)
|
|
||||||
goto ret_result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (debug_display && cname)
|
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, cname));
|
|
||||||
if (tm && cname) {
|
|
||||||
tm1 = Getattr(tm, cname);
|
|
||||||
if (tm1) {
|
|
||||||
result = Getattr(tm1, tm_method); /* See if there is a type - name match */
|
|
||||||
if (result)
|
|
||||||
goto ret_result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (debug_display)
|
|
||||||
Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, 0));
|
|
||||||
if (tm) {
|
|
||||||
result = Getattr(tm, tm_method); /* See if there is simply a type match */
|
|
||||||
if (result)
|
|
||||||
goto ret_result;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
SwigType *nprim = SwigType_default(primitive);
|
SwigType *nprim = SwigType_default(primitive);
|
||||||
Delete(primitive);
|
Delete(primitive);
|
||||||
|
|
@ -862,8 +797,6 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
||||||
result = backup;
|
result = backup;
|
||||||
|
|
||||||
ret_result:
|
ret_result:
|
||||||
Delete(template_prefix);
|
|
||||||
Delete(noarrays);
|
|
||||||
Delete(primitive);
|
Delete(primitive);
|
||||||
if ((unstripped) && (unstripped != type))
|
if ((unstripped) && (unstripped != type))
|
||||||
Delete(unstripped);
|
Delete(unstripped);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue