|
RE: Wrapping exception handling around a constructor called from Java: msg#00075programming.swig
You are correct, of course. My example was missing the 'try {' and the closing brace. My real code was being correctly processed by Swig, wrapping the constructor and destructor calls, as you pointed out. Good to know that one can wrap *only* the ctor. By the way, I was able to correctly implement Java Callbacks from a the native library by writing callback interceptor logic for the Java and C++ sides, as you described earlier. It took a while to figure out, but it works reliably. Thanks for the help on that. -----Original Message----- From: William S Fulton [mailto:wsf@xxxxxxxxxxxxxxxxxxx] Sent: Wednesday, November 12, 2003 1:26 PM To: Willis, Raymond W Cc: swig@xxxxxxxxxxxxxxx Subject: Re: [Swig] Wrapping exception handling around a constructor called from Java Willis, Raymond W wrote: > Hi > > I understand how to use %exception to get SWIG to add native exception > handling code around a call to a native method, and have used it > successfully. > > How does one do the same for native constructors that are instantiated > as the result of being instantiated up at the Java layer? > > I tried this (Foo is the native class being wrapped) > > %exception Foo { > $action > } catch ( std:exception err) { > // handle exception > } > > But this does not get put into the generated C++ JNI code. > %exception Foo {...} works for me. But it also adds the code to the destructor! Best to use Foo::Foo. Try this %exception Foo::Foo { // %exception for Foo $action } %inline %{ class Foo { public: Foo() {} }; %} The code you posted looks as though it is missing the 'try {' and a closing brace. That may be the problem. William _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Wrapping exception handling around a constructor called from Java: 00075, William S Fulton |
|---|---|
| Next by Date: | %typemap(argout) does not support sequences of consecutive argume nts.: 00075, David Benjamin-bdavid02 |
| Previous by Thread: | Re: Wrapping exception handling around a constructor called from Javai: 00075, William S Fulton |
| Next by Thread: | RE: Wrapping exception handling around a constructor called from Java: 00075, Willis, Raymond W |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |