Fix spacing in generated code for csdirectorin 'pre', 'post' and 'terminator' attributes. Add some more tests for these attributes.

This commit is contained in:
William S Fulton 2013-01-11 06:19:24 +00:00
commit 13d9e19cdb
3 changed files with 41 additions and 46 deletions

View file

@ -15,6 +15,11 @@ public class csharp_prepost_runme {
Assert(vpost.Count, 2);
vpost.Add(1.0);
}
public override int methodint(ref double[] vpre, DoubleVector vpost)
{
method(ref vpre, vpost);
return vpost.Count;
}
}
public static void Main() {
{
@ -58,6 +63,17 @@ public class csharp_prepost_runme {
Assert(vpre[0], 2.0);
Assert(vpost.Count, 3);
}
{
PrePost3_Derived p = new PrePost3_Derived();
double[] vpre = new double[] { 1.0 };
DoubleVector vpost = new DoubleVector();
vpost.Add(3.0);
vpost.Add(4.0);
int size = p.methodint(ref vpre, vpost);
Assert(vpre[0], 2.0);
Assert(vpost.Count, 3);
Assert(size, 3);
}
// Check attributes are generated for the constructor helper function
{

View file

@ -80,14 +80,14 @@ struct PrePost2 {
// Check csdirectorin pre and post attributes
// ref param
%typemap(csdirectorin,
pre=" DoubleVector d$iminput = new DoubleVector($iminput, false);\n"
" int count$iminput = d$iminput.Count;\n"
" double[] v$iminput = new double[count$iminput];\n"
" for (int i=0; i<count$iminput; ++i) {\n"
" v$iminput[i] = d$iminput[i];\n"
" }\n",
pre=" DoubleVector d$iminput = new DoubleVector($iminput, false);\n"
" int count$iminput = d$iminput.Count;\n"
" double[] v$iminput = new double[count$iminput];\n"
" for (int i=0; i<count$iminput; ++i) {\n"
" v$iminput[i] = d$iminput[i];\n"
" }\n",
post=" foreach (double d in v$iminput) {\n"
" d$iminput.Add(d);\n"
" d$iminput.Add(d);\n"
" }\n"
) std::vector<double> &vpre
"ref v$iminput"
@ -106,6 +106,7 @@ struct PrePost3 {
}
virtual ~PrePost3(){}
virtual void method(std::vector<double> & vpre, std::vector<double> & vpost) {}
virtual int methodint(std::vector<double> & vpre, std::vector<double> & vpost) { return 0; }
};
%}