When using Swig to wrap C++ code, it is possible to add methods to the native C++ type using %extend
. It is possible to add methods to the C# wrapper class using
In order to write your own version you're going to need to make sure it doesn't clash with the default one. I think the easiest way to do this would be to make ItemChanged
private/protected using %csmethodmodifiers
and %rename
to hide the default wrapped version that gets generated. Once it's hidden.
You can then safely write your own version of ItemChanged
using a cscode typemap that firstly calls the private version and then calls your additional code as you desire.
This is by far the cleanest way of solving the problem - the only way you're able to inject code directly into the generated code is as part of the argument/return value marshalling - setting up the arguments that get passed in, cleaning up after or handling the return value. Messing with one of those typemaps to inject some code would be fairly messy.