From 2a3e687c19385bb516b89343ffa0f347465ade82 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 16 Apr 2013 11:11:20 +0200 Subject: [PATCH] Octave: fix bugs in output of cleanup code Closes #35 --- CHANGES.current | 6 ++++++ Source/Modules/octave.cxx | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 254ecf8ba..926096cab 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -8,6 +8,12 @@ Version 2.0.10 (in progress) 2013-04-17: wsfulton [C#] Pull patch #34 from BrantKyser to fix smart pointers in conjuction with directors. +2013-04-15: kwwette + [Octave] Fix bugs in output of cleanup code. + - Cleanup code is now written also after the "fail:" label, so it will be called if + a SWIG_exception is raised by the wrapping function, consistent with other modules. + - Octave module now also recognises the "$cleanup" special variable, if needed. + 2013-04-08: kwwette Add -MP option to SWIG for generating phony targets for all dependencies. - Prevents make from complaining if header files have been deleted before diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index a9be76fc2..bf2552a30 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -744,10 +744,15 @@ public: Delete(tm); } - Printf(f->code, "fail:\n"); // we should free locals etc if this happens Printf(f->code, "return _out;\n"); + Printf(f->code, "fail:\n"); // we should free locals etc if this happens + Printv(f->code, cleanup, NIL); + Printf(f->code, "return octave_value_list();\n"); Printf(f->code, "}\n"); + /* Substitute the cleanup code */ + Replaceall(f->code, "$cleanup", cleanup); + Replaceall(f->code, "$symname", iname); Wrapper_print(f, f_wrappers); DelWrapper(f);