dexception.swg 1.1 KB

123456789101112131415161718192021222324252627282930
  1. /* -----------------------------------------------------------------------------
  2. * dexception.swg
  3. *
  4. * Typemaps used for propagating C++ exceptions to D.
  5. * ----------------------------------------------------------------------------- */
  6. // Code which is inserted into the dout typemaps and class constructors via
  7. // excode if exceptions can be thrown.
  8. %define SWIGEXCODE "\n if ($imdmodule.SwigPendingException.isPending) throw $imdmodule.SwigPendingException.retrieve();" %enddef
  9. %typemap(throws, canthrow=1) int,
  10. long,
  11. short,
  12. unsigned int,
  13. unsigned long,
  14. unsigned short
  15. %{ char error_msg[256];
  16. sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
  17. SWIG_DSetPendingException(SWIG_DException, error_msg);
  18. return $null; %}
  19. %typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY],
  20. enum SWIGTYPE, const enum SWIGTYPE &
  21. %{ (void)$1;
  22. SWIG_DSetPendingException(SWIG_DException, "C++ $1_type exception thrown");
  23. return $null; %}
  24. %typemap(throws, canthrow=1) char *
  25. %{ SWIG_DSetPendingException(SWIG_DException, $1);
  26. return $null; %}