mirror of https://github.com/swig/swig
template template parameters patch tidyup
- Document change in CHANGES file - Minor tweaks and whitespace fixes in stype.c - Enhance testcase - Synchronise Java and Python runt test in testcase
This commit is contained in:
parent
cbfc0d15b1
commit
b3bc87d551
|
@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.1.0 (in progress)
|
||||
===========================
|
||||
|
||||
2021-03-22: goto40
|
||||
#1977 Fix handling of template template parameters.
|
||||
|
||||
2021-03-21: olly
|
||||
#1929, #1978 [PHP] Add support for PHP 8.
|
||||
|
||||
|
|
|
@ -36,6 +36,11 @@ public class template_template_parameters_runme {
|
|||
intContainer1.setX(91);
|
||||
if (intContainer1.getX() != 91)
|
||||
throw new RuntimeException("Failed");
|
||||
if (intTestStruct.getX().getX() != 91)
|
||||
throw new RuntimeException("Failed");
|
||||
IntTestStruct intTestStructReturned = template_template_parameters.TestStructContainer1Method(intTestStruct);
|
||||
if (intTestStructReturned.getX().getX() != 101)
|
||||
throw new RuntimeException("Failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
from template_template_parameters import *
|
||||
|
||||
# Test first part
|
||||
listBool = ListFastBool()
|
||||
listBool.item = True
|
||||
x_boolean = listBool.allotype
|
||||
if listBool.item != True:
|
||||
raise RuntimeError("Failed")
|
||||
|
||||
listDouble = ListDefaultDouble()
|
||||
listDouble.item = 10.2
|
||||
x_double = listDouble.allotype
|
||||
if listDouble.item != 10.2:
|
||||
raise RuntimeError("Failed")
|
||||
|
||||
# Test second part
|
||||
floatTestStruct = FloatTestStruct()
|
||||
floatContainer2 = floatTestStruct.x
|
||||
|
@ -11,4 +24,7 @@ if intContainer1.x!=91:
|
|||
raise RuntimeError("Failed")
|
||||
if intTestStruct.x.x != 91:
|
||||
raise RuntimeError("Failed")
|
||||
intTestStructReturned = TestStructContainer1Method(intTestStruct)
|
||||
if intTestStructReturned.x.x != 101:
|
||||
raise RuntimeError("Failed")
|
||||
|
||||
|
|
|
@ -48,6 +48,11 @@ struct TestStruct {
|
|||
TemplateTemplateT<BaseT> x;
|
||||
};
|
||||
|
||||
TestStruct<int, Container1> TestStructContainer1Method(TestStruct<int, Container1> ts1) {
|
||||
ts1.x.x += 10;
|
||||
return ts1;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
/* part 1 */
|
||||
|
@ -61,8 +66,8 @@ struct TestStruct {
|
|||
%template(DoubleAllocFast) pfc::alloc_fast<double>;
|
||||
|
||||
/* part 2 */
|
||||
%template(IntTestStruct) TestStruct<int, Container1>;
|
||||
%template(FloatTestStruct) TestStruct<float, Container2>;
|
||||
%template(IntContainer1) Container1<int>;
|
||||
%template(FloatContainer2) Container2<float>;
|
||||
%template(IntTestStruct) TestStruct<int, Container1>;
|
||||
%template(FloatTestStruct) TestStruct<float, Container2>;
|
||||
|
||||
|
|
|
@ -1296,14 +1296,14 @@ void SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
|||
* with "pat=TemplateTemplateT"
|
||||
* we need to compare only the first part of the string e.
|
||||
*/
|
||||
int len = DohLen(pat);
|
||||
int len = Len(pat);
|
||||
|
||||
/* DohLen(e) > len, not >= (because we expecte at least a
|
||||
/* Len(e) > len, not >= (because we expect at least a
|
||||
* character '<' following the template typename)
|
||||
*/
|
||||
if (DohLen(e)>len) {
|
||||
if (Len(e) > len) {
|
||||
String *firstPartOfType = NewStringWithSize(e, len);
|
||||
const char* e_as_char = DohData(e);
|
||||
const char* e_as_char = Char(e);
|
||||
|
||||
if (Equal(firstPartOfType, pat) && e_as_char[len] == '<') {
|
||||
String *repbase = SwigType_templateprefix(rep);
|
||||
|
@ -1311,7 +1311,6 @@ void SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
|||
Delete(repbase);
|
||||
}
|
||||
Delete(firstPartOfType);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue