PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/modula3/exception/example.i

#
Swig | 43 lines | 33 code | 8 blank | 2 comment | 0 complexity | 25f1b2038c4976945ccef70a9dd917ad MD5 | raw file
 1/* File : example.i */
 2%module Example
 3
 4%{
 5#include "example.h"
 6%}
 7
 8%insert(m3wrapintf) %{
 9EXCEPTION E(Error);
10%}
11%insert(m3wrapimpl) %{
12IMPORT Ctypes AS C;
13%}
14
15%pragma(modula3) enumitem="enum=error;int;srcstyle=underscore;Error";
16
17%typemap("m3rawintype")   double & %{C.double%};
18%typemap("m3wrapintype")  double & %{LONGREAL%};
19
20%typemap("m3wraprettype") error ""
21%typemap("m3wrapretvar") error "rawerr: C.int;"
22%typemap("m3wrapretraw")  error "rawerr"
23%typemap("m3wrapretcheck:throws") error "E"
24%typemap("m3wrapretcheck") error
25%{VAR err := VAL(rawerr, Error);
26BEGIN
27IF err # Error.ok THEN
28RAISE E(err);
29END;
30END;%}
31
32%typemap("m3rawintype")              errorstate & %{C.int%};
33%typemap("m3wrapintype",numinputs=0) errorstate & %{%};
34%typemap("m3wrapargvar")             errorstate & %{err:C.int:=ORD(Error.ok);%};
35%typemap("m3wrapoutcheck:throws")    errorstate & "E";
36%typemap("m3wrapoutcheck")           errorstate &
37%{IF VAL(err,Error) # Error.ok THEN
38RAISE E(VAL(err,Error));
39END;%}
40
41/* Let's just grab the original header file here */
42
43%include "example.h"