PageRenderTime 63ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-24/SWIG/Examples/modula3/exception/example.i

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