Re: [C#] Add code to all non-static methods
Alexander Vostres <[email protected]> Wed, 27 Oct 2021 23:11:07 +0300
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CAGbZuBd2xWs-Rf3XkR3dbn8Wp-RLuSPEtgDd6s5KkD4pPqTfDA@mail.gmail.com> |
I want to validate "this" pointer on the C# side (swigCPtr). The value of null, while valid, produces an AccessViolationException down the stack that cannot be caught by default in .NET Framework and at all in .NET Core runtimes, which means taking down the entire application which is not necessarily a good thing. On Wed, Oct 27, 2021 at 9:12 PM William S Fulton <[email protected]> wrote: > Are you referring to the 'this' pointer or to parameters in a method? If > parameter, that types of parameters? A nullptr is entirely valid of course > of pointer types in C++. Maybe you want to modify the default SWIGTYPE *, > SWIGTYPE & and SWIGTYPE typemaps. > > William > > > On Mon, 25 Oct 2021 at 11:08, Alexander Vostres <[email protected]> > wrote: > >> Greetings, >> Basically, I'd like to add null check to throw NullReference instead of >> getting (non-catchable) AccessViolation from the C++ side. >> To do this I need to add something along the lines of "if (ptr == null) >> throw;" to all the non-static methods. >> So far the closest I've got is modifying csout, however, it applies to >> all the methods. >> Is there any way to apply a modified csout typemap only to non-static >> methods? Or is there any other way to insert couple lines of code into all >> the methods? >> >> Alex >> _______________________________________________ >> Swig-user mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/swig-user >> > _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user