PageRenderTime 54ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Lib/perl5/perltypemaps.swg

#
Unknown | 95 lines | 65 code | 30 blank | 0 comment | 0 complexity | ea990addaeaef63b412a477e502d378a MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* ------------------------------------------------------------
  2. * Typemap specializations for Perl
  3. * ------------------------------------------------------------ */
  4. /* ------------------------------------------------------------
  5. * Fragment section
  6. * ------------------------------------------------------------ */
  7. /*
  8. in Perl we need to pass the CPerlObj value, sometimes, so, we define
  9. the decl/call macros as needed.
  10. */
  11. #define SWIG_AS_DECL_ARGS SWIG_PERL_DECL_ARGS_2
  12. #define SWIG_AS_CALL_ARGS SWIG_PERL_CALL_ARGS_2
  13. #define SWIG_FROM_DECL_ARGS SWIG_PERL_DECL_ARGS_1
  14. #define SWIG_FROM_CALL_ARGS SWIG_PERL_CALL_ARGS_1
  15. /* Include fundamental fragemt definitions */
  16. %include <typemaps/fragments.swg>
  17. /* Look for user fragments file. */
  18. %include <perlfragments.swg>
  19. /* Perl fragments for primitive types */
  20. %include <perlprimtypes.swg>
  21. /* Perl fragments for char* strings */
  22. %include <perlstrings.swg>
  23. /* ------------------------------------------------------------
  24. * Unified typemap section
  25. * ------------------------------------------------------------ */
  26. /* No director supported in Perl */
  27. #ifdef SWIG_DIRECTOR_TYPEMAPS
  28. #undef SWIG_DIRECTOR_TYPEMAPS
  29. #endif
  30. /* Perl types */
  31. #define SWIG_Object SV *
  32. #define VOID_Object sv_newmortal()
  33. /* Perl $shadow flag */
  34. #define %newpointer_flags $shadow
  35. #define %newinstance_flags $shadow
  36. /* Complete overload of the output/constant/exception macros */
  37. /* output */
  38. %define %set_output(obj) $result = obj; argvi++ %enddef
  39. /* append output */
  40. %define %append_output(obj) if (argvi >= items) EXTEND(sp,1); %set_output(obj) %enddef
  41. /* variable output */
  42. %define %set_varoutput(obj) sv_setsv($result,obj) %enddef
  43. /* constant */
  44. %define %set_constant(name, obj) %begin_block
  45. SV *sv = get_sv((char*) SWIG_prefix name, TRUE | 0x2 | GV_ADDMULTI);
  46. sv_setsv(sv, obj);
  47. SvREADONLY_on(sv);
  48. %end_block %enddef
  49. /* raise exception */
  50. %define %raise(obj, type, desc) sv_setsv(get_sv("@", GV_ADD), obj); SWIG_fail %enddef
  51. /* Include the unified typemap library */
  52. %include <typemaps/swigtypemaps.swg>
  53. /* ------------------------------------------------------------
  54. * Perl extra typemaps / typemap overrides
  55. * ------------------------------------------------------------ */
  56. %typemap(varout,type="$1_descriptor") SWIGTYPE *, SWIGTYPE []
  57. "sv_setiv(SvRV($result),PTR2IV($1));";
  58. %typemap(varout,type="$1_descriptor") SWIGTYPE &
  59. "sv_setiv(SvRV($result),PTR2IV(&$1));";
  60. %typemap(varout,type="$&1_descriptor") SWIGTYPE
  61. "sv_setiv(SvRV($result), PTR2IV(&$1));";
  62. %typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) {
  63. SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor);
  64. }
  65. %typemap(varout) SWIGTYPE *const = SWIGTYPE *;