From 01aec38ae995017fb565798857c73d0180540e38 Mon Sep 17 00:00:00 2001 From: Simon Marchetto Date: Mon, 7 Apr 2014 11:40:31 +0200 Subject: [PATCH] scilab: add missing lib sciexception.swg --- Lib/scilab/sciexception.swg | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Lib/scilab/sciexception.swg diff --git a/Lib/scilab/sciexception.swg b/Lib/scilab/sciexception.swg new file mode 100644 index 000000000..5135cab9c --- /dev/null +++ b/Lib/scilab/sciexception.swg @@ -0,0 +1,46 @@ +/* + * Exception typemaps (throws) + */ + +%typemap(throws, noblock=1) int, unsigned int, signed int, + int&,unsigned int&, signed int&, + long, unsigned long, signed long, + short, unsigned short,signed short, + long long, unsigned long long, + unsigned char, signed char, + long&, unsigned long&, signed long&, + short&, unsigned short&, signed short&, + long long&, unsigned long long&, + unsigned char&, signed char& { + char obj[20]; + sprintf(obj, "%d", $1); + %raise(obj, "$type", $descriptor); +} + +%typemap(throws, noblock=1) enum SWIGTYPE { + char obj[20]; + sprintf(obj, "%d", $1); + %raise(obj, "$type", $descriptor); +} + +%typemap(throws, noblock=1) float, double, + float&, double& { + char obj[20]; + sprintf(obj, "%5.3f", $1); + %raise(obj, "$type", $descriptor); +} + +%typemap(throws, noblock=1) char*, char[ANY] { + %raise($1, "$type", $descriptor); +} + +%typemap(throws, noblock=1) SWIGTYPE, + SWIGTYPE*, + SWIGTYPE [ANY], + SWIGTYPE & { + %raise(NULL, "$type", $descriptor); +} + +%typemap(throws, noblock=1) (...) { + SWIG_exception_fail(SWIG_RuntimeError,"unknown exception"); +}