[PHP] Fix getters for template members. (SF#3428833)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13096 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b32c70e244
commit
de9d01dbcd
5 changed files with 78 additions and 20 deletions
|
|
@ -475,6 +475,7 @@ CPP_STD_TEST_CASES += \
|
|||
li_std_string \
|
||||
li_std_vector \
|
||||
li_std_vector_enum \
|
||||
li_std_vector_member_var\
|
||||
naturalvar \
|
||||
smart_pointer_inherit \
|
||||
template_typedef_fnc \
|
||||
|
|
|
|||
23
Examples/test-suite/li_std_vector_member_var.i
Normal file
23
Examples/test-suite/li_std_vector_member_var.i
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
%module li_std_vector_member_var
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
%template(vectorDbl) std::vector<double>;
|
||||
|
||||
%inline %{
|
||||
#include <vector>
|
||||
|
||||
typedef std::vector<double> DblVector;
|
||||
|
||||
struct Test {
|
||||
DblVector v;
|
||||
int x;
|
||||
|
||||
Test() : x(0) { }
|
||||
|
||||
void f(int n) {
|
||||
x += n;
|
||||
v.push_back(1.0 / n);
|
||||
}
|
||||
};
|
||||
%}
|
||||
24
Examples/test-suite/php/li_std_vector_member_var_runme.php
Normal file
24
Examples/test-suite/php/li_std_vector_member_var_runme.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "li_std_vector_member_var.php";
|
||||
|
||||
$t = new Test();
|
||||
|
||||
check::equal($t->x, 0, "Test::x != 0");
|
||||
check::equal($t->v->size(), 0, "Test::v.size() != 0");
|
||||
|
||||
$t->f(1);
|
||||
check::equal($t->x, 1, "Test::x != 1");
|
||||
check::equal($t->v->size(), 1, "Test::v.size() != 1");
|
||||
|
||||
$t->f(2);
|
||||
check::equal($t->x, 3, "Test::x != 3");
|
||||
check::equal($t->v->size(), 2, "Test::v.size() != 2");
|
||||
|
||||
$t->f(3);
|
||||
check::equal($t->x, 6, "Test::x != 6");
|
||||
check::equal($t->v->size(), 3, "Test::v.size() != 3");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue