fix $typemap() when the type contains template parameters
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11506 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5161a12868
commit
41d3c98993
5 changed files with 48 additions and 2 deletions
|
|
@ -14,6 +14,8 @@ public class runme {
|
||||||
throw new Exception("test failed");
|
throw new Exception("test failed");
|
||||||
if (special_variable_macros.testJim(name) != "multiname num")
|
if (special_variable_macros.testJim(name) != "multiname num")
|
||||||
throw new Exception("test failed");
|
throw new Exception("test failed");
|
||||||
|
if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
|
||||||
|
throw new Exception("test failed");
|
||||||
NewName newName = NewName.factory("factoryname");
|
NewName newName = NewName.factory("factoryname");
|
||||||
name = newName.getStoredName();
|
name = newName.getStoredName();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ public class special_variable_macros_runme {
|
||||||
throw new RuntimeException("test failed");
|
throw new RuntimeException("test failed");
|
||||||
if (!special_variable_macros.testJim(name).equals("multiname num"))
|
if (!special_variable_macros.testJim(name).equals("multiname num"))
|
||||||
throw new RuntimeException("test failed");
|
throw new RuntimeException("test failed");
|
||||||
|
if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
|
||||||
|
throw new RuntimeException("test failed");
|
||||||
NewName newName = NewName.factory("factoryname");
|
NewName newName = NewName.factory("factoryname");
|
||||||
name = newName.getStoredName();
|
name = newName.getStoredName();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,6 @@ if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap":
|
||||||
raise "test failed"
|
raise "test failed"
|
||||||
if special_variable_macros.testJim(name) != "multiname num":
|
if special_variable_macros.testJim(name) != "multiname num":
|
||||||
raise "test failed"
|
raise "test failed"
|
||||||
|
if special_variable_macros.testJohn(special_variable_macros.PairIntBool(10, False)) != 123:
|
||||||
|
raise "test failed"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,40 @@ const char * testJim(Name *jim, int count) {
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Template types with more than one template parameter
|
||||||
|
|
||||||
|
// check $1 and $input get expanded properly when used from $typemap()
|
||||||
|
%typemap(in) Space::Pair<int, bool> PAIR_INT_BOOL ($1_type temp)
|
||||||
|
%{
|
||||||
|
/*%typemap(in) Name *GENERIC start */
|
||||||
|
temp = Space::Pair<int, bool>(123, true);
|
||||||
|
(void)$input;
|
||||||
|
$1 = ($1_ltype)temp;
|
||||||
|
/*%typemap(in) Name *GENERIC end */
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(in) Space::Pair<int, bool> john {
|
||||||
|
// %typemap(in) Name *john start
|
||||||
|
$typemap(in, Space::Pair<int, bool> PAIR_INT_BOOL)
|
||||||
|
// %typemap(in) Name *john end
|
||||||
|
}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
namespace Space {
|
||||||
|
template <typename T1, typename T2> struct Pair {
|
||||||
|
Pair(T1 f, T2 s) : first(f), second(s) {}
|
||||||
|
Pair() {}
|
||||||
|
T1 first;
|
||||||
|
T2 second;
|
||||||
|
};
|
||||||
|
int testJohn(Space::Pair<int, bool> john) {
|
||||||
|
return john.first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
%template(PairIntBool) Space::Pair<int, bool>;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
// A real use case for $typemap
|
// A real use case for $typemap
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1699,9 +1699,10 @@ static List *split_embedded_typemap(String *s) {
|
||||||
List *args = 0;
|
List *args = 0;
|
||||||
char *c, *start;
|
char *c, *start;
|
||||||
int level = 0;
|
int level = 0;
|
||||||
|
int angle_level = 0;
|
||||||
int leading = 1;
|
int leading = 1;
|
||||||
args = NewList();
|
|
||||||
|
|
||||||
|
args = NewList();
|
||||||
c = strchr(Char(s), '(');
|
c = strchr(Char(s), '(');
|
||||||
assert(c);
|
assert(c);
|
||||||
c++;
|
c++;
|
||||||
|
|
@ -1720,7 +1721,7 @@ static List *split_embedded_typemap(String *s) {
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((level == 0) && ((*c == ',') || (*c == ')'))) {
|
if ((level == 0) && angle_level == 0 && ((*c == ',') || (*c == ')'))) {
|
||||||
String *tmp = NewStringWithSize(start, c - start);
|
String *tmp = NewStringWithSize(start, c - start);
|
||||||
Append(args, tmp);
|
Append(args, tmp);
|
||||||
Delete(tmp);
|
Delete(tmp);
|
||||||
|
|
@ -1735,6 +1736,10 @@ static List *split_embedded_typemap(String *s) {
|
||||||
level++;
|
level++;
|
||||||
if (*c == ')')
|
if (*c == ')')
|
||||||
level--;
|
level--;
|
||||||
|
if (*c == '<')
|
||||||
|
angle_level++;
|
||||||
|
if (*c == '>')
|
||||||
|
angle_level--;
|
||||||
if (isspace((int) *c) && leading)
|
if (isspace((int) *c) && leading)
|
||||||
start++;
|
start++;
|
||||||
if (!isspace((int) *c))
|
if (!isspace((int) *c))
|
||||||
|
|
@ -1901,6 +1906,7 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
||||||
}
|
}
|
||||||
Delete(l);
|
Delete(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (syntax_error) {
|
if (syntax_error) {
|
||||||
String *dtypemap = NewString(dollar_typemap);
|
String *dtypemap = NewString(dollar_typemap);
|
||||||
Replaceall(dtypemap, "$TYPEMAP", "$typemap");
|
Replaceall(dtypemap, "$TYPEMAP", "$typemap");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue