From: William S F. <ws...@fu...> - 2005-12-21 23:17:50
|
Olly Betts wrote: > On 2005-12-21, William S Fulton <ws...@fu...> wrote: >>There is no differentiation between prefix and postfix in C#. Also in C# >>the method is static and it takes different parameters. > > Ah, I'd not spotted the difference with static and parameters. I was > under the misaprehension that C# effectively just needed the prefix C++ > version. > >>So morphing the C++ declaration into a C# one isn't so natural. The >>easiest approach is to just add in the correct C# declaration into >>your C# class as such: >> >>%rename(operator_plus_plus) operator ++; >>%typemap(cscode) Op %{ >> public static Op operator++(Op op) { >> return op.operator_plus_plus(); >> } >>%} > > Good plan - that'll do nicely. Might be worth adding this idea to the > manual. > >>You should be able to make the generated/renamed function private with: >> >>%csmethodmodifiers operator++ "private"; > > To stop people calling the "operator_plus_plus" directly method you > mean? It'd be neater if they couldn't, but I hardly see that as a huge > problem. > Yeah, it is becomes an implementation detail method which a user does not need to know about. William |