G***@ubsw.com
2003-02-27 10:26:37 UTC
Hi,
I am successfully using Swig to wrap a C++ class hierarchy into a Java class hierarchy, using Swig 1.3.17
Concerning default arguments....
If I have a class member function like
void f(int i1, int i2 = 0); //the second int has a default value
the equivalent C wrapped function has something like
...
int arg3 = (int) 0; //where arg3 corresponds to my i2
...
arg3 = (int) jarg3; //!oops loosing the default value
Am I missing something on the default args mechanism?
I understand that this might be an issue with simple types (int), but the same happens if the argument is an object passed by value or reference. There is no check if the JNI argument is null (which could be used to represent defaults) or not. Eventually the default value is always lost.
At best an exception is thrown.
Is there any way to use effectively the default argument mechanism?
Thanks for your help.
Gualtiero Chiaia
UBS Warburg - London
Visit our website at http://www.ubswarburg.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.
I am successfully using Swig to wrap a C++ class hierarchy into a Java class hierarchy, using Swig 1.3.17
Concerning default arguments....
If I have a class member function like
void f(int i1, int i2 = 0); //the second int has a default value
the equivalent C wrapped function has something like
...
int arg3 = (int) 0; //where arg3 corresponds to my i2
...
arg3 = (int) jarg3; //!oops loosing the default value
Am I missing something on the default args mechanism?
I understand that this might be an issue with simple types (int), but the same happens if the argument is an object passed by value or reference. There is no check if the JNI argument is null (which could be used to represent defaults) or not. Eventually the default value is always lost.
At best an exception is thrown.
Is there any way to use effectively the default argument mechanism?
Thanks for your help.
Gualtiero Chiaia
UBS Warburg - London
Visit our website at http://www.ubswarburg.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.