From: William S F. <ws...@fu...> - 2011-08-17 21:56:46
|
On 12/08/11 01:14, Gregory Bronner wrote: > Is there support for adding method annotations to C# or Java methods? > > e.g. in java: > > @SpecialMethod > void doSomething() > > or in C# > [SpecialMethod] > public void doSomething() > > I suppose one could try to use csmethodmodifiers, but I was hoping that there was something that came out of the 2009 Google Summer of Code. > There is support for C# attributes, see the C# documentation and search for 'type attributes' and 'C# attributes'. There are some testcases you can look at in Examples/test-suite/csharp_attributes.i and Examples/test-suite/csharp/csharp_attributes_runme.cs. The equivalent could be ported to the Java language module but has not been implemented. > > Also, it would be nice if there was support for non-static module functions in C# and Java: > > i.e instead of > [DllImport("SierraQuantLib", EntryPoint="CSharp_new_AC1D_d")] > public static extern IntPtr new_AC1D_d(double[] jarg1, int jarg2); > > we could get SWIG to generate a static method that called a class function > > [DllImport("SierraQuantLib", EntryPoint="CSharp_new_AC1D_d")] > private static extern IntPtr new_AC1D_d_internal(double[] jarg1, int jarg2); > > public static IntPtr new_AC1D_d(double[] jarg1, int jarg2) { > return instance().new_ACID_d_hookable(); > } > public IntPtr new_AC1D_d(double[] jarg1, int jarg2) { > return new_ACID_d_internal(); > } > > This allows you to inherit the module from some other class and install class method hooks. > > I have a working implementation, albeit not implemented as a feature directive. > Perhaps you could use aspects instead, via the attributes mentioned above? Currently you could use the 'csout' typemap, where you can put in some hooks in the module class and proxy class C# wrapper methods which call into the intermediary class methods. William |