SWIG has support for including code that is executed when loading a module, as follows:
%init %{
init_variables();
%}
Does something similar also exist for finalization? I can not find any documentation on it, maybe there is another good way to achieve the same thing for finalization?
You could register an
atexitcleanup routine during%init. Here’s a working sample:Result: