pybackward.swg 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. adding backward compatibility macros
  3. */
  4. #define SWIG_arg(x...) %arg(x)
  5. #define SWIG_Mangle(x...) %mangle(x)
  6. #define SWIG_As_frag(Type...) %fragment_name(As, Type)
  7. #define SWIG_As_name(Type...) %symbol_name(As, Type)
  8. #define SWIG_As(Type...) SWIG_As_name(Type) SWIG_AS_CALL_ARGS
  9. #define SWIG_Check_frag(Type...) %fragment_name(Check, Type)
  10. #define SWIG_Check_name(Type...) %symbol_name(Check, Type)
  11. #define SWIG_Check(Type...) SWIG_Check_name(Type) SWIG_AS_CALL_ARGS
  12. %define %ascheck_methods(Code, Type...)
  13. %fragment(SWIG_As_frag(Type),"header", fragment=SWIG_AsVal_frag(Type)) {
  14. SWIGINTERNINLINE Type
  15. SWIG_As(Type)(PyObject* obj)
  16. {
  17. Type v;
  18. int res = SWIG_AsVal(Type)(obj, &v);
  19. if (!SWIG_IsOK(res)) {
  20. /*
  21. this is needed to make valgrind/purify happier.
  22. */
  23. memset((void*)&v, 0, sizeof(Type));
  24. SWIG_Error(res, "");
  25. }
  26. return v;
  27. }
  28. }
  29. %fragment(SWIG_Check_frag(Type),"header",fragment=SWIG_AsVal_frag(Type)) {
  30. SWIGINTERNINLINE int
  31. SWIG_Check(Type)(PyObject* obj)
  32. {
  33. int res = SWIG_AsVal(Type)(obj, (Type*)0);
  34. return SWIG_IsOK(res);
  35. }
  36. }
  37. %enddef
  38. %apply_checkctypes(%ascheck_methods)