PageRenderTime 23ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Lib/perl5/perlinit.swg

#
Unknown | 81 lines | 71 code | 10 blank | 0 comment | 0 complexity | 40feb969f81f2ecf1f2c7906d6926bf6 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* Export the SWIG initialization function */
  2. %header %{
  3. #ifdef __cplusplus
  4. extern "C"
  5. #endif
  6. #ifndef PERL_OBJECT
  7. #ifndef MULTIPLICITY
  8. SWIGEXPORT void SWIG_init (CV* cv);
  9. #else
  10. SWIGEXPORT void SWIG_init (pTHXo_ CV* cv);
  11. #endif
  12. #else
  13. SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *);
  14. #endif
  15. %}
  16. /* Module initialization function */
  17. %insert(init) "swiginit.swg"
  18. %init %{
  19. #ifdef __cplusplus
  20. extern "C"
  21. #endif
  22. XS(SWIG_init) {
  23. dXSARGS;
  24. int i;
  25. SWIG_InitializeModule(0);
  26. /* Install commands */
  27. for (i = 0; swig_commands[i].name; i++) {
  28. // Casts only needed for Perl < 5.10.
  29. #ifdef __cplusplus
  30. newXS(const_cast<char*>(swig_commands[i].name), swig_commands[i].wrapper, const_cast<char*>(__FILE__));
  31. #else
  32. newXS((char*)swig_commands[i].name, swig_commands[i].wrapper, (char*)__FILE__);
  33. #endif
  34. }
  35. /* Install variables */
  36. for (i = 0; swig_variables[i].name; i++) {
  37. SV *sv;
  38. sv = get_sv(swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI);
  39. if (swig_variables[i].type) {
  40. SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0);
  41. } else {
  42. sv_setiv(sv,(IV) 0);
  43. }
  44. swig_create_magic(sv, swig_variables[i].name, swig_variables[i].set, swig_variables[i].get);
  45. }
  46. /* Install constant */
  47. for (i = 0; swig_constants[i].type; i++) {
  48. SV *sv;
  49. sv = get_sv(swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI);
  50. switch(swig_constants[i].type) {
  51. case SWIG_INT:
  52. sv_setiv(sv, (IV) swig_constants[i].lvalue);
  53. break;
  54. case SWIG_FLOAT:
  55. sv_setnv(sv, (double) swig_constants[i].dvalue);
  56. break;
  57. case SWIG_STRING:
  58. sv_setpv(sv, (const char *) swig_constants[i].pvalue);
  59. break;
  60. case SWIG_POINTER:
  61. SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0);
  62. break;
  63. case SWIG_BINARY:
  64. SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
  65. break;
  66. default:
  67. break;
  68. }
  69. SvREADONLY_on(sv);
  70. }
  71. %}