Add the ability for special variable macros to call other special variable macros. Also added additional diagnostics when using -debug-tmsearch. Add tests for std::vector of shared_ptr.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12059 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7b2c6b477a
commit
e2ce97f397
6 changed files with 116 additions and 5 deletions
17
Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs
Normal file
17
Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using li_boost_shared_ptr_bitsNamespace;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
VectorIntHolder v = new VectorIntHolder();
|
||||
v.Add(new IntHolder(11));
|
||||
v.Add(new IntHolder(22));
|
||||
v.Add(new IntHolder(33));
|
||||
|
||||
int sum = li_boost_shared_ptr_bits.sum(v);
|
||||
if (sum != 66)
|
||||
throw new ApplicationException("sum is wrong");
|
||||
}
|
||||
}
|
||||
24
Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java
Normal file
24
Examples/test-suite/java/li_boost_shared_ptr_bits_runme.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import li_boost_shared_ptr_bits.*;
|
||||
|
||||
public class li_boost_shared_ptr_bits_runme {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_boost_shared_ptr_bits");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
VectorIntHolder v = new VectorIntHolder();
|
||||
v.add(new IntHolder(11));
|
||||
v.add(new IntHolder(22));
|
||||
v.add(new IntHolder(33));
|
||||
|
||||
int sum = li_boost_shared_ptr_bits.sum(v);
|
||||
if (sum != 66)
|
||||
throw new RuntimeException("sum is wrong");
|
||||
}
|
||||
}
|
||||
|
|
@ -23,3 +23,28 @@ struct NonDynamic {
|
|||
boost::shared_ptr<NonDynamic> boing(boost::shared_ptr<NonDynamic> b) { return b; }
|
||||
%}
|
||||
|
||||
// vector of shared_ptr
|
||||
%include "std_vector.i"
|
||||
|
||||
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
|
||||
|
||||
%shared_ptr(IntHolder);
|
||||
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
#include "boost/shared_ptr.hpp"
|
||||
struct IntHolder {
|
||||
int val;
|
||||
IntHolder(int a) : val(a) {}
|
||||
};
|
||||
int sum(std::vector< boost::shared_ptr<IntHolder> > v) {
|
||||
int sum = 0;
|
||||
for (size_t i=0; i<v.size(); ++i)
|
||||
sum += v[i]->val;
|
||||
return sum;
|
||||
}
|
||||
%}
|
||||
|
||||
%template(VectorIntHolder) std::vector< boost::shared_ptr<IntHolder> >;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,3 +18,14 @@ check(nd)
|
|||
b = boing(nd)
|
||||
check(b)
|
||||
|
||||
################################
|
||||
|
||||
v = VectorIntHolder()
|
||||
v.push_back(IntHolder(11))
|
||||
v.push_back(IntHolder(22))
|
||||
v.push_back(IntHolder(33))
|
||||
|
||||
sum = sum(v)
|
||||
if sum != 66:
|
||||
raise "sum is wrong"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue