diff options
author | Swati Sharma <itawswati@gmail.com> | 2012-08-08 16:01:21 +0000 |
---|---|---|
committer | Swati Sharma <itawswati@gmail.com> | 2012-08-08 16:01:21 +0000 |
commit | 789b437f062cbe0c68fbda8ead770c1b1654a4b6 (patch) | |
tree | 4c7feb24d8325bbc2f99465bf7b65b2305fd0533 | |
parent | 0f4a324742920fa85c168bed3bc5611aff0b74c1 (diff) | |
download | swig-789b437f062cbe0c68fbda8ead770c1b1654a4b6.tar.gz |
Added contract Support.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-objc@13564 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rwxr-xr-x | Lib/objc/objcruntime.swg | 6 | ||||
-rw-r--r-- | Source/Modules/objc.cxx | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/Lib/objc/objcruntime.swg b/Lib/objc/objcruntime.swg index 8a4c92ca1..a2e8fb385 100755 --- a/Lib/objc/objcruntime.swg +++ b/Lib/objc/objcruntime.swg @@ -9,3 +9,9 @@ #include <stdlib.h> #include <string.h> %} + +%insert(runtime) %{ +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) { /*throw exception*/ return nullreturn; } else +%} diff --git a/Source/Modules/objc.cxx b/Source/Modules/objc.cxx index 5b9088693..07ded5685 100644 --- a/Source/Modules/objc.cxx +++ b/Source/Modules/objc.cxx @@ -907,6 +907,14 @@ int OBJECTIVEC::functionWrapper(Node *n) { // Final substititions if applicable. + /* Contract macro modification */ + Replaceall(wrapper->code, "SWIG_contract_assert(", "SWIG_contract_assert($null, "); + + if (!is_void_return) + Replaceall(wrapper->code, "$null", "0"); + else + Replaceall(wrapper->code, "$null", ""); + // Dump the function out. Wrapper_print(wrapper, wrap_mm_code); @@ -1142,7 +1150,7 @@ void OBJECTIVEC::emitProxyClassFunction(Node *n) { Printf(proxyfunctionname, "%s", Char(variable_name) + 1); } else if (member_func_flag) { - proxyfunctionname = Copy(symname); + proxyfunctionname = Copy(name); } else { proxyfunctionname = Swig_scopename_last(name); } |