Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#59 Operator support wth C# target language

open
nobody
None
5
2012-12-21
2007-11-28
Koro
No

Currently when parsing a class that has operators, SWIG complains the following:

1>c:\...\file.h(nnn): Warning(503): Can't wrap 'operator xx' unless renamed to a valid identifier.

I think it would be fairly easy to add operator support for C# to SWIG.

Right now, I'm doing this for every operator (pseudo-code, replace xx and params to appropriate):

%extend Class
{
%rename(%mangle(operator xx)) operator xx;
%csmethodmodifiers operator xx "private";
}

%typemap(cscode) Class
%{
// This returns bool for a comparision operator
public static Class operator xx (Class v1, params)
{
v1.operator_xx_(params)
}
%}

This obviously could be made totally automatic.

Thanks.

Discussion