SF Patch#268 - Add 'pre', 'post' and 'terminator' attributes to the csdirectorin typemap
"csdirectorin" "pre:" and "post" code attributes in C# module. Without them it is not trivial to marshal strings and smart-pointers back and forth between user callback code and native code. (especially by reference) Also fixes 2 minor issues in director code generation that are difficult to come by until "csdirectorin" attribute is extended. The first is that "ref" types used in directors lead to invalid signature generation (the type array used to match methods possibly overloaded by user). typeof(ref T) is used instead of typeof().MakeByRefType() The second is that ignored director methods are not completely ignored - if there was a %typemap(imtype, "directorinattributes") it is not skipped for ignored method.
This commit is contained in:
parent
f9566ad2df
commit
2b407f4b27
4 changed files with 147 additions and 9 deletions
|
|
@ -5,6 +5,17 @@ using csharp_prepostNamespace;
|
|||
|
||||
public class csharp_prepost_runme {
|
||||
|
||||
class PrePost3_Derived : PrePost3
|
||||
{
|
||||
public PrePost3_Derived(){}
|
||||
public override void method(ref double[] vpre, DoubleVector vpost)
|
||||
{
|
||||
Assert(vpre[0], 1.0);
|
||||
vpre[0] = 2.0;
|
||||
Assert(vpost.Count, 2);
|
||||
vpost.Add(1.0);
|
||||
}
|
||||
}
|
||||
public static void Main() {
|
||||
{
|
||||
double[] v;
|
||||
|
|
@ -37,6 +48,17 @@ public class csharp_prepost_runme {
|
|||
Assert(v[1], 8.8);
|
||||
}
|
||||
|
||||
{
|
||||
PrePost3_Derived p = new PrePost3_Derived();
|
||||
double[] vpre = new double[] { 1.0 };
|
||||
DoubleVector vpost = new DoubleVector();
|
||||
vpost.Add(3.0);
|
||||
vpost.Add(4.0);
|
||||
p.method(ref vpre, vpost);
|
||||
Assert(vpre[0], 2.0);
|
||||
Assert(vpost.Count, 3);
|
||||
}
|
||||
|
||||
// Check attributes are generated for the constructor helper function
|
||||
{
|
||||
CsinAttributes c = new CsinAttributes(5);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue